I would like to be able to query whether or not a service is running from a windows batch file. I know I can use:
sc query \"ServiceName\"
Use Cygwin Bash with:
sc query "SomeService" |grep -qo RUNNING && echo "SomeService is running." || echo "SomeService is not running!"
(Make sure you have sc.exe in your PATH.)
sc.exe