r/computertechs • • Aug 27 '15

Need help writing a script NSFW

I am not sure if I'm posting in the right place, but I need help writing a script. I am wanting to have a batch file I can run to change the Recovery options when a service fails. Right now I have to go in and manually change "First failure...", "Second failure...", but it would be so great if I could just run a batch file or script to change that for me on any computer I am working on. Can anyone point me in the right direction?

7 Upvotes

4 comments sorted by

1

u/bibleharmony Aug 27 '15

Thanks again f34rinc. I tested and that worked perfect.

1

u/f34rinc Aug 27 '15

Try

SC Failure ServiceName actions= restart/60000/restart/60000// reset= 120

This command will make a service restart after 1 minute (60000 milliseconds) on the first 2 failures, and take no action at further failures. The failures counter will be reset after 2 minutes (120 seconds)

http://ss64.com/nt/sc.html

2

u/bibleharmony Aug 27 '15

Thank you. I think this is exactly like what I'm looking for. I use Screen Connect to remote into my customers and some malware scanners will kill the service during the scan. I like setting the service up to restart when that happens. Thanks again!

1

u/_LeggoMyEggo_ Home-based residential repairs Aug 28 '15

Good idea. I've been setting this manually but throwing a script into both my GFI/Max dashboard and having it on-hand as a SC on-demand command will be handy.

SC Failure "ScreenConnect Client (dontforgettheGUID)" actions= restart/60000/restart/60000// reset= 120