The other day I found myself needing to both stop and disable a bunch of services in windows XP on multiple machines. After doing this manually through the Windows GUI on a few machines, I decided to figure out how to do it using the command line.

  • First, you’ll need to find the name of the service that you’d like to modify. Click Start > Run, type “services.msc” and click OK.050109_services1
  • The MMC will pop up and list every service on the machine along with its “Current Status” and “Startup Type”. Every service is either in the “Started” or “Stopped” state, and is set to run based on the value in “Startup Type” (Maunal, Automatic, or Disabled).050109_services2
  • Find the service you would like to modify using your batch script. For this example we will use DHCP Client. Double-click the service and a properties window will appear showing you the details of the selected service. The information you’ll need from this window is the Service Name. For the DHCP Client, the service name is “Dhcp”.050109_services3
  • Modifying services via the command line or via batch is done by using the command sc (Service Controller). For this example, I’ll discuss stopping and disabling the service, but you can see all that is possible by typing sc /? at a command prompt.
  • To stop a service, type sc stop [service name] at the command prompt. For this example, the command would be sc stop Dhcp
  • To disable a service, type sc config [service name] start= disabled at the command prompt. For this example, the command would be sc config Dhcp start= disabled (yes you need the space after the equals sign)

That’s it! You could then compile as many of these commands into one batch file for easy and/or remote execution. For details on creating Windows batch files, click here.

Posted in Windows No Comments leaf