The SC subcommands
The "sc" command comes
with numerous subcommands. A list can be seen by entering "sc /?"
into a command prompt. There is also a list in the Windows 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.
Table I. Selected subcommands for 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 aresc config
ServiceName start=
flagHere 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 is sc config
ServiceName start= demand
Note that there must be a space after the equals
sign. The correct value for the parameter ServiceName may 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 commandsc 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, use sc query type= driver
Or for a list of everything, use sc query state= all
sc start
To start up a service that is not running, usesc start
ServiceName
sc stop
To stop a running service, use sc stop
ServiceName
However, some services cannot or should not be stopped.