SC.exe – Windows CMD Command

Service Control – Create, Start, Stop, Query or Delete any Windows SERVICE. The command options for SC are case sensitive.

Note the qryOpt options above are case sensitive – they must be entered in lower case, also the position of spaces and = must be exactly as shown.

The SC command duplicates some aspects of the NET command but adds the ability to create a service.

Query a Service state

SC query will display if a service is running, giving output like this:

To retrieve specific information from SC’s output, pipe into FIND or FindStr
e.g.

The statements above will return an %ERRORLEVEL% = 1 if the text is not found

IF errorlevel 1 GOTO :my_subroutine
The NET START command can be used in a similar way to check if a service is running:

Watch out for extra spaces:
SC QUERY state= all Works
SC QUERY state =all Fails!

Start a Service

Start the schedule service:

SC start schedule

The service control manager will normally wait up to 30 seconds to allow a service to start, you can modify this time (30,000 milliseconds) in the registry

HKLM\SYSTEM\CurrentControlSet\Control
ServicesPipeTimeout (REG_DWORD)

Some options only take effect at the point when the service is started e.g. the SC config command allows the executable of a service to be changed. When the service next starts up it will run the new executable. Config changes requires the current user to have “permission to configure the service”.

PowerShell

Like every other external command SC can be run under PowerShell instead of CMD, however there is one extra complication for SC and that is the standard PowerShell alias SC which redirects to the Set-Content cmdlet.

To avoid that, use the call operator to run SC.exe from PowerShell:

Examples:

Disable Windows Update (Windows 10)

To re-enable Windows Update set the start= back to auto and start the services.

Enable remote registry access on computer64:

You may also like...

3 Responses

  1. Lettie says:

    I have fun with, lead to I found just what I used to be
    looking for. You have ended my four day lengthy hunt!

    God Bless you man. Have a great day. Bye

  2. zortilo nrel says:

    Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks

  3. froleprotrem says:

    I adore reading and I conceive this website got some truly useful stuff on it! .

Leave a Reply

Your email address will not be published.