Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating a batch file to start several services, instead of enumerating each "net start" with the exact service name, how can i create the script to run "net start" on any service that begins with "EED"


share|improve this question
up vote 0 down vote accepted

If you're open to using PowerShell instead of a batch file, this one liner will fix you up.

Get-Service EED* | Start-Service

share|improve this answer
this worked perfectly – user20849 Aug 30 '10 at 21:20
or wmic service where "name like 'eed$'" call startservice – tony roth Aug 31 '10 at 1:04

A FOR-IN-DO loop is one way you could do this.

FOR %%x in ("Service 1" "Service 2" "Service ...") DO net start %%x

The syntax may vary, depending on the service name and optional parameters. Of course, this doesn't meet your requirement to enumerate the list based on service names that start with "EED." You will have to list each service specifically, or use more complex code to get that done. Type FOR /? at a command prompt for more information on the extensive options that this command provides.

share|improve this answer

Here is a batch file to do exactly that:

@Echo Off
for /f "tokens=1,2" %%i in ('sc query') do if "%%i"=="SERVICE_NAME:" call :Process %%j
Goto :EOF

set @Name=%1
if "%@Name:~0,3%"=="EED" (SC start %1
Echo %1 Started)


If you want to change the "prefix search" change the line that says:

if "%@Name:~0,3%"=="EED" (SC start %1

The prefix to search for is the "EED" and you have to make sure that you change the length number, which is the "~0,3" part... if you want all services that start with "Exchange" then change that number to "~0,8"



share|improve this answer
I just realized that this is not a one line command... sorry. but it is possible to make this a generic batch file that would work like "StartServicesWithPrefix EED" but it would take a bit more work. Glenn – Glenn Sullivan Aug 30 '10 at 19:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.