1

I have a service well running and configured on my windows OS The service runs as the PC starts, but some times it crashes when there is no internet connection on PC boot and due to that, it does not start at all. My goal is to let that service restart on failure for a few seconds until internet is back else. I've followed what is written in the Microsoft documentation and I used the "sc.exe" commandline tool to accomplish this. Here is the command I've used:

C:\Windows\System32\sc.exe failure $nameOfService reset= 10 actions= restart/1000/restart/5000/restart/100000

But, when I test my service, it does not restart. Please is there something wrong with the above command ?

John Code
  • 655
  • 7
  • 24
  • Is the service configured correctly when you look in the 'services' UI? Is the 'Recovery' tab set as expected? Did you write the service? If so, you probably should fix the bug that is crashing it first. If not and if the issue is a timing issue at boot with the network not being available quickly enough, can you try setting the service to [deleyed start](https://stackoverflow.com/questions/11015189/automatic-vs-automatic-delayed-start/11015576#11015576) as this means there will be an extra 2 minutes before it is started, by which time the network is more likely to be available? – boxdog Oct 04 '19 at 09:34
  • Hi, thanks for your reply. Yes the service is configured correctly. I've tried delaying the service automatic start, but the ideal scenario will be to restart the service. I've analysed the cause of the crash, but after I fix, I'll still need to implement service restart, so that the service should be resilient. – John Code Oct 04 '19 at 09:58

0 Answers0