How to restart a windows service using Task Scheduler

Kurt Van den Branden picture Kurt Van den Branden · Mar 30, 2016 · Viewed 150.9k times · Source

The easiest way to do this is to create a batch file with:

NET stop <service name>
NET start <service name>

Once the batch file is created and tested, add it to Windows Task Scheduler and run it at a specific time interval. Problem here is, when the bat file is missing or corrupt, the service won't restart. So, are there other ways to restart a service at a specific time interval?

Answer

Kurt Van den Branden picture Kurt Van den Branden · Mar 30, 2016

Instead of using a bat file, you can simply create a Scheduled Task. Most of the time you define just one action. In this case, create two actions with the NET command. The first one to stop the service, the second one to start the service. Give them a STOP and START argument, followed by the service name.

In this example we restart the Printer Spooler service.

NET STOP "Print Spooler" 
NET START "Print Spooler"

enter image description here

enter image description here

Note: unfortunately NET RESTART <service name> does not exist.