We all work with Windows applications which have interactive system services to handle. Sometimes we tend to mend the registry keys to configure the service settings, which is never a Best Practice!!.
Sc.exe is a Service Management Utility which solves this purpose. It is a command line program which is primarily used for communicating with the Service Control Manager (SCM) and the services. With this utility, you can do the below operations with ease.
- Query the status of a service
- Create a service using a command line
- Start, pause, continue and stop a service
- Interrogate control requests to a service
- Change the configuration of a service
- Change the actions taken by the service upon failure
- Query the service SID type of a service
- Queries the triggered parameters of a services (Triggered Services is a model implemented in Windows 7)
- Enumerates service dependencies
- You can also lock the SCM database
The general usage of this command would be.,
sc <server> [command] [service name] <option1> <option2>..
Developers and administrators should never edit the registry to configure service settings. Instead, they should use sc.exe, the services MMC snap-in, or the SCM client API.
Few Examples Usages:
By using a triggerinfo switch we can get the status of a trigger service “browser” and its status, along with the port configurations
In this example, we just use the query switch which displays the type, state, exit code, checkpoint and the wait_hint for the “bits” service.
Windows also includes an MMC snap-in—services.msc—that provides basic SCM functionality through a graphical user interface.