views:

446

answers:

5

My primary computer for programming is the same computer I use for gaming etc. So to increase speed while gaming I turned off services like Apache, MySQL, Subversion etc. from starting at boot as I use it about 50/50 for gaming/programming.

This is fine most of the time but it's a bit of a nuisance to start them all separately.

Could someone show me how to write a batch file or something similar to start all the services?

+3  A: 

Well you can write a batch file like

net start "Service Name"

There should be a way to dependency link the services together also, so when one starts all the others will too. I'll see if I can find the switch to do that.

EDIT:

I haven't tried this, but this should tell you where to find in the registry to make the services dependent on each other and all start automatically:

http://www.softwaretipsandtricks.com/windowsxp/articles/490/1/Removing-Service-Dependencies

Kevin
+3  A: 

The command for starting a service is "net start <servicename>". Just add the ones you need to a file called Something.bat and run it. simple. :)

net stop <service name> will also stop them.

Craig
A: 

An easier way:

  1. Install ps tools (it has a lot of really cool cmd line tools for developers)

  2. One of the tools that ps tools comes with is PsService

  3. you can start stop your services using start and stop

Bogdan Gavril
+2  A: 

You can also have the services start in parallel by calling:

SC START servicename

I don't know if that helps...

I wouldn't mess with the dependencies for services unless you really know what you're doing.

Larry Osterman
For this question, 'sc' is the better method as it starts the service asynchronously, moving onto the next batch command.
spoulson
A: 

If you're using powershell, you can do this:

"service1", "service2" | %{ start-service $_ }

To explain the above, it's as follows:

  1. create an array containing "service1" and "service2"
  2. pipe that array to the foreach command (which is the % sign)
  3. the foreach command will run the code block (delimited by { } ), and the "current item" is represented by $_
  4. It will therefore run start-service on each of the things in your array
Orion Edwards