简体   繁体   中英

sc.exe alternative to find deactivated Windows service?

I use sc.exe to stop/start services on a remote \\server in a pre/post build batch. Unfortunately sc does not seem to deliver any information about the service being deactivated or not which leads to an accumulating timeout when using the sc start command on deactivated services. Does anyone know an alternative to check the deactivated state on a remote service in the command line?

This is what you are looking for..

How to test whether a service is running from the command line

look down for the WMI/WMIC options. You will need to modify the command line slightly to attach to a remote machine.

If you need to know the start mode property, add it to the command line like this:

wmic /locale:ms_409 service where (name="RemoteRegistry") get state, StartMode /Value

This produces:

StartMode=Disabled
State=Stopped

I am not marking as duplicate because your wording and needs are a little bit different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM