The sc (service controller) command manages Windows services from the command line. This can be integral to any semi-automated failover mechanism, service watchdog, or a mass update that requires some configuration to the service.
For Windows Server 2003 and Windows Server 2008 environments, the sc command takes the familiar 'net start' to additional levels by allowing a service to be set to disabled, automatic or manual, as well as control functions to the service in the current state.
You might use the sc command if you need to update something on your environment, and you need to stop a monitoring service that every server uses. In this situation, you could stop each monitoring agent on each server and make the service disabled with the following code:
sc SERVER1 stop "AlertManagerService"
sc SERVER1 config " AlertManagerService " start= disabled
If you use the sc command in reverse, it can enable and restart the service. With the sc command, you can have one central script execute service configuration tasks on multiple servers remotely when the appropriate permissions are available.
When using the sc command, the service name may not match the name you see in the Windows services MMC snap-in. If you use a BlackBerry Enterprise Server (BES), you may have the BlackBerry MDS service installed on your BES server. This service is an example where the display name does not match that of the service name. With the sc command, you can run the following command:
sc email-bes001 GetDisplayName MdsTomcat
The command will give the display name from the services MMC snap-in; from there, you can relate it to your functional needs. The image below shows the output of running this command.
The sc command parameters are consistent across Windows Server 2003, Windows Server 2008, and Windows XP, making mixed platform deployments simplified, with only the ShowSid string available on Windows Server 2008.
While the sc command was delivered in the Windows NT era, it is still valuable in mass deployments today for service management.
This was published in 



Leave a comment