sc - Manage Services
The sc command manages Windows services. A service is a program that keeps running in the background without anyone signing in, such as printing, Windows Update, or networking features.
With sc, you can check a service’s status, start and stop it, and change its startup type (automatic, manual, or disabled) entirely from the command line. You do not need to open the Services window (services.msc), which also makes sc a good fit for batch files.
Basic Syntax of the sc Command
sc <command> <service name> [options]
The first argument says what to do, followed by the name of the target service. The main commands are as follows.
| Command | Description |
|---|---|
sc query | Show the status of a service |
sc qc | Show a service’s configuration (startup type, etc.) |
sc start | Start a service |
sc stop | Stop a service |
sc pause | Pause a service |
sc continue | Resume a paused service |
sc config | Change a service’s configuration (startup type, etc.) |
sc create | Register a new service |
sc delete | Delete a service registration |
In Windows PowerShell 5.1, sc is an alias for the Set-Content cmdlet. Typing sc query Spooler there does not manage services, so include the extension, as in sc.exe query Spooler. The commands in this article assume you are running them in Command Prompt.
Service Name vs. Display Name
Every service has a display name shown in services.msc (for example, Print Spooler) and a separate service name that you use in commands (for example, Spooler). sc takes the service name.
The output of sc query shows the service name (SERVICE_NAME) next to the display name (DISPLAY_NAME), so you can match them up.
Check the Status of a Service
Run sc query with the service name.
sc query Spooler
STATE is the current status. The main values are as follows.
| STATE value | Meaning |
|---|---|
RUNNING | Running |
STOPPED | Stopped |
START_PENDING | Starting up |
STOP_PENDING | Shutting down |
PAUSED | Paused |
Running sc query without a service name lists the running services. To include stopped services as well, specify state= all.
sc query type= service state= all
sc options need a space right after the =, as in type= service. Writing type=service causes an error. Do not put a space before the =.
When the list is long, combine it with more or find to make it easier to read.
sc query type= service state= all | find "SERVICE_NAME"
Check a Service’s Configuration
sc qc (query config) shows the startup type and the path to the executable.
sc qc Spooler
START_TYPE shows the startup type, and BINARY_PATH_NAME shows the service’s executable.
Start and Stop a Service
Use sc start to start a service and sc stop to stop it.
sc start Spooler
sc stop Spooler
Starting, stopping, and reconfiguring a service usually requires administrator rights. Running these in a normal Command Prompt gives “Access is denied” (error 5). See the related article for how to run as administrator. Checking status (sc query) works without administrator rights.
sc stop only sends a stop request and does not wait for the service to finish stopping. Right after running it you may see STOP_PENDING, so wait a moment and then use sc query to confirm it has reached STOPPED.
Restart a Service
sc has no restart command, so stop the service and start it again. Insert timeout to give the service time to stop.
@echo off
sc stop Spooler
timeout /t 3 /nobreak >nul
sc start Spooler
Some services take longer than 3 seconds to stop. When you need to be sure, use the “Wait for a State” technique described below.
How It Differs from net start and net stop
net start <service name> and net stop <service name> can also start and stop services.
net stop Spooler
net start Spooler
net stop waits until the service has stopped before returning. It also stops any services that depend on it, after asking for confirmation. If you simply want to stop and start a service, net is more convenient. If you also need to check status or change configuration, sc is the better choice.
Change the Startup Type
The start= option of sc config changes what happens when Windows starts.
sc config Spooler start= demand
| Value | Startup type |
|---|---|
auto | Automatic |
delayed-auto | Automatic (delayed start) |
demand | Manual |
disabled | Disabled |
Disabling a service makes the features that depend on it unavailable from the next startup onward. Do not change the configuration of a service you do not understand. Note the current settings with sc qc before changing anything so you can restore them.
Errors and How to Fix Them
When sc fails, it prints a message with an error number, such as [SC] OpenService FAILED 1060:.
| Error | Common cause and fix |
|---|---|
| 5 | Access denied. Run as administrator |
| 1056 | The service is already running. Check the state with sc query |
| 1060 | The service does not exist. Check that you used the service name, not the display name |
| 1058 | The service cannot be started because it is disabled. Change the startup type with sc config |
| 1062 | The service has not been started (you tried to stop one that is already stopped) |
You can look up the meaning of an error number with net helpmsg, as in net helpmsg 1060.
Check the State in a Batch File
Searching the output of sc query with find tells you whether a service is running.
@echo off
sc query Spooler | find "RUNNING" >nul
if errorlevel 1 (
echo Print Spooler is stopped.
) else (
echo Print Spooler is running.
)
find returns exit code 0 when it finds a matching line and 1 when it does not, so if errorlevel 1 handles the “not found” case. The STATE values are in English regardless of the display language, so the same code works on any Windows language.
Wait for a State
To wait for a start or stop to finish, check repeatedly until the state reaches the value you want.
@echo off
sc stop Spooler >nul
:wait
sc query Spooler | find "STOPPED" >nul
if errorlevel 1 (
timeout /t 1 /nobreak >nul
goto wait
)
echo Stopped.
If the service cannot stop, this example waits forever. For real use, it is safer to set a maximum number of attempts with a counter variable.
Register and Delete a Service
sc create registers your own program as a service. Give the path to the executable in binPath=.
sc create MyService binPath= "C:\tools\myservice.exe" start= demand
When you no longer need it, remove the registration with sc delete.
sc delete MyService
sc delete removes the service registration without asking for confirmation. Deleting a service that ships with Windows can leave the system unable to work correctly. Use it only on services you registered yourself.
Note that an ordinary program or batch file does not work as a service as is. To run as a service, a program must be able to respond to requests from the Service Control Manager.
Summary
| What you want to do | Command |
|---|---|
| Check a service’s status | sc query <service name> |
| List all services | sc query type= service state= all |
| Check startup type and settings | sc qc <service name> |
| Start a service | sc start <service name> |
| Stop a service | sc stop <service name> |
| Change the startup type | sc config <service name> start= demand |
| Test whether a service is running | sc query <service name> | find "RUNNING" |
| Register or delete a service | sc create / sc delete |