This allows the service to clean up after itself. If the service runs into a problem and needs to restart, I launch a thread that stops the service from the SCM. so the service manager will restart this After downloading updates, Windows 10 automatically picks a time to restart your computer for you, based on when you tend to not use it (e.g., 3 am), but. if there was a problem, set an exit error code Schedule Automatic Restarts in Windows 10. This also assumes you have set up the service to restart on an error. Without this flag you won't be able to stop the service manually from the SCM. You can create a bootable disk with a healthy computer with Windows 10 with the help of professional partition manager software - EaseUS Partition Master. When Windows 10 keeps restarting, you can directly get this issue solved right now with a Windows bootable disk. To do this you need to set a flag before you terminate that tells the OnStop method to exit with an error code then the SCM knows that the service needs to be restarted. Fix Windows 10 Reboot Loop by Booting PC from the Bootable Disk. Then all your cleanup code will run, and you won't have any hanging sockets or other processes, assuming your stop code is doing its job. The cleanest way to do this that I have found is to use the OnStop() method, which is the entry point for the Service Control Manager. It can be a hardware issue like bad RAM, faulty hard-disk, corrupted registry, drivers not updated, incompatibility of graphic drivers.
This problem was there in 1809 version also.
The problem with shelling out to a batch file or EXE is that a service may or may not have the permissions required to run the external app. Computer keeps restarting in Windows 10 because of software or hardware issues.