I am trying to find a commandline method for setting the Enable actions for stops with errors
check box in the Recovery
tab of a service's properties dialogue.
I know that when I change the value of the check box and hit apply, in the registry the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<serviceName>\FailureActionsOnNonCrashFailures
key is modified to be either 0
or 1
.
However, it seems that something else on the system must be changing because manually setting the registry key value is not enough to turn that check box on or off in the dialogue UI, and it's not enough to change the value returned when running sc qfailureflag <servicename>
.
Even running sc failureflag <servicename> flag=1
or flag=0
does not change the value returned by sc qfailureflag <servicename>
and does not affect the check box in UI, and indeed does not even seem to change the value of that registry key, even though checking or unchecking the box in the UI does change that key's value.
The only method I can find that seems to have any effect on whether that flag is truly 'set' or not, is clicking in the UI. Clicking in the UI does change both the registry key and the value returned by sc qfailureflag
Since I'm trying to write a configuration script that will set this flag automatically, clicking in the UI is not an option.
If anyone knows what else is changing on the system to set or un set this flag I would love to know, and if you know an automated way to set it that would be even better. Ideally some mix of PowerShell and C# would be great too, but honestly I would settle for just knowing what is changing on the system that I'm not seeing.