laurian
laurian

Reputation: 809

Manually reset Windows Service Failure Count

I configured my Windows Service recovery as following:

Now I would like to reset the failure count after the third failure so that when an admin manually restarts the service, the service can be automatically recovered anew.

So far, the only solution I found is to reset the counter is uninstalling / reinstalling the service which I find not clean. Any idea how to do that?

Upvotes: 2

Views: 3083

Answers (1)

David Jones
David Jones

Reputation: 3342

The service control manager counts the number of times each service has failed since the system booted. The count is reset to 0 if the service has not failed for dwResetPeriod seconds.

Calling ChangeServiceConfig2 with the dwResetPeriod of SERVICE_FAILURE_ACTIONS set to 0 will reset the count.

You will need to query (see QueryServiceConfig2) the original setting of dwResetPeriod, set it to zero then reset it back to the original to preserve the state.

Upvotes: 2

Related Questions