How to remotely change Windows service restart options from a command line

As an IT sysadmin you may often need to change the service restart actions to be taken in the event of a system service failure.  In large environments you’ll obviously want to do this from a script if possible, so the following command should do what you want if you’re tring to remove all restart actions from the Spooler service running on REMOTESERVER:

sc.exe \\REMOTESERVER failure spooler actions= “” reset= 0}

You can wrap this up inside a command prompt or PowerShell loop as follows (PowerShell example).  Please note the extra quotes to allow PowerShell to parse the command line and still pass the correct parameters to sc.exe.  In the example below, the change to remove all recovery actions from the Spooler service will be applied to SERVER01 – SERVER08.

1..8 | foreach {sc.exe \\SERVER0$_ failure spooler actions= “””””” reset= 0}

Please type sc.exe failure help at the command prompt for more details on this functionality.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: