Configuring service restart with ‘restart service after’ parameter

windows-service

It appears that sc.exe isn't capable of setting the 'restart service after' parameter and powershell isn't capable of setting up service restarts at all.

My intended configuration is failure1/restart failure2/restart failure3/nothing with a five minute counter between each restart. The five minute timer is extremely important.

Is there anything else I can look at other than some registry hackery configure this?

Best Answer

The failure response is stored in the REG_BINARY value FailureActions under HKLM\SYSTEM\CurrentControlSet\services\<SERVICE_NAME>. You'll probably have to set it the way you want it on one machine using services.msc, grab the data from the FailureActions value in the Registry, and then script the configuration with reg add (or reg import if using a .REG file).