You can set your Windows computer to shut down or restart automatically by using the built-in shutdown.exe command and the Task Scheduler job.
If you need to schedule a one-time restart or shutdown of Windows after a period of time, you can use the shutdown.exe command. This command allows you to specify the number of seconds to wait before shutting down the computer.
For example, if you want to shut down the computer after 1 hour (3600 seconds), you can execute this command:
shutdown /s /t 3600
The following Windows pop-up message will appear:
You’re about to be signed out. Windows will shut down in 60 minutes.
Shutdown will start on ….
Change the /s option to /r if you need to restart your computer:
shutdown /r /t 3600
If you want to cancel a scheduled shutdown of Windows, run the following command:
shutdown /a
A message should appear:
Logoff is canceled
The scheduled shutdown has been canceled.
If you need to restart or shut down Windows on a regular basis, you will need to use Task Scheduler.
For example, your task is to automatically restart your Windows computer every weekday at midnight.
- Open the Task Scheduler MMC snap-in from the Control Panel or run the taskschd.msc command;
- Expand the Task Scheduler library and create a new folder to store your tasks;
- Right-click and select Create Basic Task;
- Specify a task name: AutoRestartMidnight;
- Specify that you want to run the task on a Weekly basis;
- Select the weekdays and time to restart Windows (12 AM);
- Select Action > Start a program;
- In the Program/Script field, type: %SYSTEMROOT%\System32\shutdown.exe
- Specify the following options in the Add argument:
/r /f /t 300 /c "Midnight automatic restart. To cancel run: shutdown.exe /a"
Note. This command reboots Windows after 5 minutes (300 seconds) and displays the notification with the text specified in the /c argument.
- Click Next > Finish.
In order to run this task with administrator permissions, open the task’s properties, enable the Run with highest privileges option, and change the Change User or Group to NT AUTHORITY\SYSTEM.
At the scheduled time, all users of the computer will see a pop-up message about the upcoming computer reboot.
If you need to cancel the reboot, press Win+R and run the command:
Shutdown /a
If the restart is not cancelled, the computer will reboot automatically after 5 minutes.
To completely cancel an automatic computer restart task, select the task in the Task Scheduler console and click Disable.