Create Batch File to Start or End Window Services

Contributor Icon Contributed by David Kirk     
Tag Icon Tagged: Batch file programming  

The windows environment can be easily changed by starting or ending various windows services. For example, this method can be used to easily shut down multiple services for a performance boost during game playing.

Update: This article was original crafted for XP; however, I continue to use this technique on my Windows 7 and Windows 8 systems. On more recent Windows systems, the batch file will need to be run as administrator.

Warning: Manipulating windows services can have unpredictable effects on your system. You should create a system restore point before experimenting.

We all want to tweak or windows systems to the extreme to get the quickest, most powerful system possible. Many people will disable multiple window services manually before game playing. What a pain!

Many times people forget what the services do or forget to restart the important ones. Services can be easily changed by creating batch files.

The important commands are the following:
NET START – starts the service
NET STOP – ends the service

For example:
NET STOP "Error Reporting Service"

Output: The Error Reporting Service service was stopped successfully.

Knowing the commands, one can now easily create batch files called something like beforegame.bat and aftergame.bat.

Before.bat would contain all the NET STOP commands to end the nonessential services.
After.bat would be exactly the same except all the NET STOP commands would be replaced with NET START commands to restart all the common services.

A sample of the before.bat file might look something like this:

NET STOP "Error Reporting Service"
NET STOP "FTP Publishing Service"
SET STOP "IIS Admin"
NET STOP "Messenger"

Likewise, the after.bat file might look something like this:

NET START "Error Reporting Service"
NET START "FTP Publishing Service"
SET START "IIS Admin"
NET START "Messenger"

You may wish to reference this: list of services that can be disabled.

If your system ever becomes unstable and you want to return the services to their default settings, the default settings for the windows services can be found here.

 

23 Comments -


  1. savita said on December 1, 2008

    Hi,

    I am using net start to start a service. but my service name has sqaure brackets soemthign like abc[32.0] and becuase of square braces its failing. does anyone know escapae sequence for this?

    many thanks
    savita.

  2. ramr said on March 6, 2009

    Would be nice to clearly add where those files should be located.

    Thks, Regards

  3. leighw said on March 7, 2009

    Does anyone know how to DISABLE a service (not just stop it) so that it wont start again on the next reboot? I have tried the following: -

    NET STOP “Service Name” (The service stops after a second or two)
    SC Config “Service Name” start= disabled

    But this error is produced on the second line: -

    [SC] OpenService FAILED 1060: The specified service does not exist as an installed service.

    Patently the service does exist as it was stopped successfully in the first line.

    Thanks, Leigh

  4. mrxbubbles said on March 30, 2009

    try double quotes on the second one around the service name

  5. Ravi said on April 21, 2009

    Thanks, But how to Enable / Disable Windows Services using DOS.

    If the service is disabled, we cannot start the service using ” net start command ”

  6. Anonymous said on October 16, 2009

    Nice one, I think it could help me cos am having a work station with oracle, SAP and microsoft SQL Server

  7. Anonymous said on October 21, 2009

    Ya Finger Crossed,
    i Was looking for Same.
    Thanks,
    Ahmad

  8. Anonymous said on November 18, 2009

    I created batch file having this entry NET STOP “MSSQLSERVER” and it is prompting me to accept Y before execution.
    How can I correct this to make auto-execute?

  9. Swati Gudla said on November 25, 2009

    Hello Everyone,
    I am very new to windows services.
    My question is..
    Is there any DOS command to figure out the running services.
    To be specific i have a windows service like “my service” i need to check the service is running or not..Is there any command to execute and see the running services…
    I would really appreciate if some one can help me out to ….

  10. Anonymous said on December 23, 2009

    sc query “my service”

    and

    net start

  11. ilaya said on May 26, 2010

    check the particular service running or not in all 100 servers.we need to check this using single server using bat file

  12. ilaya said on May 26, 2010

    can u help me bellow issue

    check the particular service running or not in all 100 servers.we need to check this using single server.

  13. ilaya said on May 26, 2010

    can u help me bellow issue

    check the particular service running or not in all 100 servers.we need to check this using single server.

  14. ilaya said on May 26, 2010

    hi sir,

    please find the below sceneraio and help me to fix this, request you to provide bat and script file for this.

    unix,windows

    We have more than 100 servers in our environment, each server we have seperate user account. Need to change the password for all 100 servers from one server.

    windows

    check the particular service running or not in all 100 servers.we need to check this using single server.

  15. Mazz said on June 3, 2010

    Wickidellic!

  16. Fuzoukwu said on August 30, 2010

    To list all running services in Win XP issue the following command at the prompt:
    C>tasklist
    Have not tried it on Vista but it is likely to work also

  17. Mulani salim said on September 25, 2010

    we can create and delete same file again and again after 2 minits ,because of that pc cant goes in ideal mode, or any other solution on that…

  18. Chandralalprabu said on October 6, 2010

    txs its working fine

  19. Spencer Dillard said on October 12, 2010

    Worked like a charm — note that it should be NET START, not SET START. I do sharepoint dev occasionally, and being able to stop/start the 20 or so services is a major help — thanks a bunch

  20. Demurphey said on November 1, 2010

    what about NET START with arguments to start the service as a different user?

  21. Nssworld said on May 18, 2011

    I am getting following error…
    Any clue why it is happening

    System error 5 has occurred.

    Access is denied.

  22. Satish said on September 7, 2011

    Thanks… its useful

  23. joao said on October 23, 2011

    Hi dear

    I am new at working with windows scripting for batch but, I wonder if you could help by sendin a script that starts and then stops my DHCP SERVER?

    Thanks

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -