1.

Solve : Query a service?

Answer» HI all,

I can't seem to figure it out for the life of me. Is it possible to query a service that is running or not? I WANTED to query a service and have a prompt that it is running or not.

Like:
reg query "HKLM\System\CurrentControlSet\Services\srservice" /v start

For this instance, I would like to be prompted if the service is running or not. The "start" value determines if it is running or not, 4 is disabled, 2 is ENABLED.

If there is another way other than QUERYING the registry, it would be helpful as well.

depending on your OS , you can use resource kit tools like sc, sclist
http://www.ss64.com/nt/sclist.htmlYou can use the NET START command to see a list of running services.

In fact, I just posted some of this same code a few questions back.

It looks like you are looking at the System Restore service, so you could use:
Code: [Select]net start | FIND /I "System Restore" >NUL
if not ERRORLEVEL 1 (
echo System Restore appears to be enabled
) else echo System Restore does not appear to be enabled


Discussion

No Comment Found