Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have installed many of our custom written services on windows boxes (does not matter if XP, Server, Vista). I always configure to "Restart the Service" on 1st, 2nd and subsequent failures. But I have never seen this work; the service simply stops (because of an error or something in the code) but does not restart.

I just noticed the "Enable Actions For Stops With Errors" checkbox. Does this have to be checked in order for the recovery to take affect if the failure was caused by an error?

thanks, Mark.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

If your services are stopping because of an error, that is logged by windows then yes, you need to tick 'Enable Actions For Stops With Errors', otherwise it will not work.

If you do not have this ticked, then it will only restart services that have stopped for legitimate or unknown reasons.

share|improve this answer
1  
Thanks - I kind of figured that. But I would have thought "Error" would be the same thing as a "failure", and hence the service should have started without checking the box. –  M Schenkel Oct 9 '09 at 2:18
    
It does seem a little odd I agree, as most of the reasons a service would fail you would think would be an error. –  Sam Oct 9 '09 at 8:33
    
No recovery action is ever to be triggered on services that have stopped for "legitimate" reasons. This answer still makes confusion upon "stop" and "failure" terms. –  matpop Oct 7 '14 at 14:57

The "Enable actions for stops with errors" checkbox was introduced with Windows Vista and Windows Server 2008, providing a single, embarrassing line of documentation:

Select Enable actions for stops with errors in order to trigger the recovery actions that the service stopped with an error.

The SC.exe program was also updated to provide a new command: failureflag. The documentation shows a bad example and doesn't really apply to Windows Server 2003, but tells us that the command:

Specifies whether recovery actions will be triggered when a service stops as the result of an error.

So, the checkbox and sc failureflag are used to set the same flag.
Let's type sc failureflag in the command prompt, we finally get a quite decent description:

Changes the failure actions flag setting of a service. If this setting is 0 (default), the Service Control Manager (SCM) enables configured failure actions on the service only if the service process terminates with the service in a state other than SERVICE_STOPPED. If this setting is 1, the SCM enables configured failure actions on the service if the service enters the SERVICE_STOPPED state with a Win32 exit code other than 0 in addition to the service process termination as above. This setting is ignored if the service does not have any failure actions configured.

A similar description can be found here.
So, the correct answer to the original question is: the configured recovery actions always take effect when your service doesn't terminate in the SERVICE_STOPPED state. "Enable actions for stops with errors" must be checked if you need to enable the recovery actions also when your service enters the SERVICE_STOPPED state, provided that the exit code is not 0 (error).

share|improve this answer

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.