Common Outputs for Windows SC Command

I’ve been doing a bit of work with Windows services lately, in particular automated deployments of Windows services, which means I’ve been using the Windows SC command a lot. The SC command (short for “Service Controller”, located at C:\Windows\System32\sc.exe) is a really easy tool used to query/install/uninstall/start/stop Windows services from the command line.

And if you want a peek under the hood, you can see Windows services in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.

At any rate, at various stages in our automation, I needed to see the output of running the SC command; I had to do this so often that I kept the output in a text file so I could quickly refer to it. So I’m now posting those outputs here, if anything for my own memory when I go looking for it again.

Service Not Installed

Command:

sc query [service_name]

Output:

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

Service Already Installed

Command:

sc create [service_name] binPath= [service_exe]

Output:

[SC] CreateService FAILED 1073:  The specified service already exists.

Service Installed and Starting

Command:

sc start [service_name]

Output:

SERVICE_NAME: [service_name]
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 2  START_PENDING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : [process_id]
        FLAGS              :

Service Installed and Running

Command:

sc query [service_name]

Output:

SERVICE_NAME: [service_name]
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Service Installed and Stopping

Command:

sc stop [service_name]

Output:

SERVICE_NAME: [service_name]
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 3  STOP_PENDING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Service Installed and Stopped

Command:

sc query [service_name]

Output:

SERVICE_NAME: [service_name]
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Featured Image: Some rights reserved by kjetikor

Leave a Reply

Your email address will not be published. Required fields are marked *