ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Quick script to change the recovery options of a Windows Service

(1/2) > >>

questorfla:
Need to change the recovery options on a windows service (for an added software) from the default "take no action" to "restart service" on at least "first and second occurrence" and probably on "all subsequent" as well.
The timing is not critical as the defaults from the GUI when used in control panel work fine but this is for some people who are not here and should not be allowed to even know that control panel exists.  :)
I almost got there with SC stated as :
          "sc failure xxxxx actions=restart/60000/restart/60000// reset=120" but not quite. Windows error-ed "invalid option" but it should work with xxxxx being the service name.

This format also may not set the subsequent failure option to restart as well which is the layout I have tested and found to work best.  I am not familiar with using SC and have never configured anything with it before.  I also saw some other more complex comands but I only need to set these three options on only this one service.
Thanks

Stoic Joker:
Don't know that I ever actually tried that, but give this a read: http://technet.microsoft.com/en-us/library/cc742019.aspx It appears that the space locations are critical and I think the actions set has to be enclosed in {}.

x16wda:
don't you need spaces between the = chars and the parameter? (like "reset= 120")?  i seem to remember that.

4wd:
As an example, the following worked fine for me, (Win8Pro x86):

sc failure browser actions=restart/60000/restart/60000/restart/60000 reset=86400

First, Second, and Subsequent actions Restart after 60 seconds, failure counter reset after 1 day for service Computer Browser (service name = browser).

Naturally, you need admin privileges.

Stoic Joker:
I was thinking like x16wda that the space was necessary also ... But that's probably just because the documentation on SC.exe says it is a requirement.. *Shrug* :D

But...
As an example, the following worked fine for me, (Win8Pro x86):

sc failure browser actions=restart/60000/restart/60000/restart/60000 reset=86400

First, Second, and Subsequent actions Restart after 60 seconds, failure counter reset after 1 day for service Computer Browser (service name = browser).-4wd (July 01, 2014, 11:14 AM)
--- End quote ---

I can confirm this spaceless version worked for me on Windows 8.1 Pro.

Navigation

[0] Message Index

[#] Next page

Go to full version