The command-line method of managing services has the advantage of being available for scripts. It also allows for quickly stopping and starting services for troubleshooting purposes. Systems administrators use it for managing services on networks and for very detailed configuration. For the average PC user, it provides a quick and easy way to turn services on and off to see how system performance is affected.
The SC subcommands
The "sc" command comes with numerous subcommands. A list can be seen at the this Microsoft page or by entering "sc /?" into a command prompt. There is also a list in the Windows XP Help and Support Center. Altogether, 24 subcommands are listed. Each subcommand in turn may have a subset of different commands. The table below shows a selection of the subcommands and their functions that are of most relevance to a typical PC owner. Much more detailed information is available at the XP Help and Support Center by searching "sc".
Command | Function |
---|---|
sc config | Configures service startup and login accounts |
sc continue | Resumes a paused service |
sc enumdepend | Lists the services that cannot run unless the specified service is running |
sc failure | Specifies what action to take upon failure of the service |
sc pause | Pauses a service |
sc qc | Displays the configuration of a particular service |
sc query | Displays information about the specified service, driver, type of service, or type of driver |
sc start | Starts a service running |
sc stop | Sends a STOP request to a service (not all will respond) |
Examples of some useful ways to apply SC
The suite of commands that are available are very powerful and allow for much configuring of services. Although not all functions will be of interest to the average PC use, some are applicable to everyday experience. You can learn if a service is runninng, stop, start. or pause it, and determine if it will run when the system is started up. Here are examples of some commands that I think might be of interest.
- sc config
- This command has a number of functions but one is to determine the status of a service at system startup. A service can be set to run automatically, manually or not at all. The commands are
sc config ServiceName start= flag
Here ServiceName is the name of the service and flag has one of the values auto, demand. or disabled . For example, to set a service to run manually the command issc config ServiceName start= demand
Note that there must be a space after the equals sign. The correct value for the parameter ServiceName my not always be obvious and the next command can be used to find it for all services. - sc query
- Information about services and drivers can be obtained with this command. Used alone it returns a list of running services with various information about the service. Lists can be inconvenient to read on a screen and they can be redirected to a text file. To create a text list of running services use the command
sc query > serviceslist.txt
The path for the text file serviceslist.txt can be anywhere that is convenient. To create a list of all services, usesc query type= service state= all > allserviceslist.txt
To create a list of active drivers, usesc query type= driver
Or for a list of everything, usesc query state= all
- sc start
- To start up a service that is not running, use
sc start ServiceName
- sc stop
- To stop a running service, use
sc stop ServiceName
However, some services cannot or should not be stopped.