13

Is there any Windows command which will show the status of a single service?

For example, I want to know whether "IIS admin service" is running or not. If it is running the command ouput should be "running".

I tried sc query type= service state= all | find "IIS Admin Service" which displayed the output:

"DISPLAY_NAME: IIS Admin Service"

I also tried net start "IIS Admin Service" | find "Running" which displays:

The requested service has already been started.

More help is available by typing NET HELPMSG 2182.

But it doesn't give me an output such as

"service name" = running / disabled / stopped

Is there a command which has output in this format?

3 Answers 3

24

Use the service name and not the display name

sc query iisadmin

2
  • This is the way I do it. You may need to look at the Properties for the Service in the Services console (Or just do sc query to get the list of them all and find the one you want)
    – Taegost
    Feb 8, 2016 at 17:42
  • The command which you gave worked for me thanks a lot
    – vikas
    Feb 9, 2016 at 12:34
14

You can use Powershell thus:

Get-Service -name 'IIS Admin Service'

0

If you're willing to use the excellent Cygwin bash, you can simply write:

sc query "Bonjour Service" |grep -qo RUNNING && echo "Bonjour is ok!" || echo "Apple Bonjour Service not running"

The trick here is to have a proper grep available, so that in this way you can catch the true/false (success) status of command. Here -q is for silent and -o is for just returning the exact match and can probably be omitted. And yes, you need to put your "sc.exe" in your PATH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.