Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any open source software for Windows that can detect the state of services that is running on Windows? The software can detect either the service is up of down. If it is down, the software will bring it up back.

share|improve this question

migrated from stackoverflow.com Mar 14 '11 at 9:17

This question came from our site for professional and enthusiast programmers.

2  
Isn't this what the Service Manager already does? –  Matt Ball Mar 14 '11 at 1:17
    
Sort of like the taskmanager. But I would like to know either there is a open source software of doing it :) –  karikari Mar 14 '11 at 1:28
    
I'm not talking about the Task Manager. The Service Manager is a separate program that comes with Windows. Go to Control Panel -> Administrative Tools -> Services, or run Services.msc. –  Matt Ball Mar 14 '11 at 3:11
    
@karikari: Take a look at the Recovery options available. The SCM already does what you need. –  wj32 Mar 14 '11 at 7:07
    
HEY GUYS I WOULD LIKE TO REINVENT THE WHEEL. I HEARD OPEN SOURCE SOFTWARE IS GOOD FOR THIS. –  ta.speot.is Mar 14 '11 at 9:24
add comment

1 Answer

up vote 1 down vote accepted

If your goal is to do something specific when a service status changes, you can use the NotifyServiceStatusChange API to register a callback function from the SCM when something happens.

Windows also provides a "Recovery" option on the Properties page for services within services.msc. You can configure the service to be automatically restarted, have another program run, etc. It all depends on your needs.

share|improve this answer
    
thank you sir. great info :) by the way,can we detect a service that is up, but it is not doing/processing anything (eg: idle)? –  karikari Mar 14 '11 at 1:37
    
I guess you could use an API to query its CPU usage, but the problem is that becomes a really difficult thing to be scientific about. Is idle <5%? <1%? Also, the service's threads could be waiting efficiently on a thread primitive like a semaphore (and not requiring any CPU time) and could come back to life at any time. If it's a service you are writing or can modify, you should code in a direct way for you to detect that it's "idle" (in your application's sense) and react accordingly. Otherwise you'll really just be guessing. –  Brian Kelly Mar 14 '11 at 4:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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