I have a service which will fail when certain resources are unavailable. I have configured it to try restarting twice, then send me an SMS on the third attempt. Unfortunately windows only gives you the option to reset the failure count after a certain number of days, whereas I really want it to reset on every third failure. The problem is that once the service is running again, one more failure will cause it to send another SMS and not even try to restart the service.
So I want to include in my SMS script some code to reset the failure counter. I have found the following registry location:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
Which contains among other things (binary) settings for failure actions, but no counter as far as I can tell.
The sc
command lets you query all sorts of stuff, but also doesn't return a failure count.
Ideally I'd like a way to query/reset the failure counter programatically, but a commandline or registry solution would be fine (since I can script them).