If you are running some application or downloading something on your system, and it’s going to take a while, do you want to just wait on that to be completed before you go away? Would not it be nice to have the system shutdown automatically after all your tasks are done? This post shows exactly this – how to schedule shutdown of your computer at a given time.
First thing you need to do is estimate how long the tasks/programs you are running would take and may be add some grace time to that. Let’s say it takes 2 more hours, then may be add another half an hour as buffer in case it’s delayed for some reason. So you would want to shutdown the system after 2.5 hours.
There are multiple ways to schedule auto shutdown. Each of these options should work on every version of Windows – Windows 7, 8 and 10.
- Simplest way is to open a command prompt and run the below command.
sleep 9000; shutdown -s
It sleeps for 9000 seconds and then shutdown the computer. If you see below error, read sleep command to get the command on to your computer.
C:\> sleep 'sleep' is not recognized as an internal or external command, operable program or batch file. C:\>
- You can use at command to schedule shutdown. Here we need to specify the exact time the command should run at. Let’s say the current time is 1pm and you want to shutdown after 2.5 hours.
at 03:30:00PM shutdown -s
In this case, you can exit the command prompt as the command is scheduled where as with ‘sleep’ you need to keep the window open.
- You can use schtasks command.
schtasks /create /sc once /tn "auto shutdown my computer" /tr "shutdown -s" /st 15:30
Schedule daily shutdown
Below I show you how to schedule automatic shutdown daily. We can use either at or schtasks for this. Below you can see example commands to schedule shutdown at 11pm every day.
At 11:00:00PM /every:M,T,W,TH,F,SA,SU shutdown -s
C:\>schtasks /create /sc daily /tn "auto shutdown my computer daily" /tr "shutdown -s" /st 23:00 SUCCESS: The scheduled task "auto shutdown my computer daily" has successfully been created.
Schedule automatic restart
The above commands are for shutting down computers. If we need to restart instead, we can simply add the right argument to the shutdown command. For example to restart computer at 11pm just for today, the command would be
at 11:00:00PM shutdown -r
If you want to use sleep
sleep number_of_seconds_to_wait; shutdown -r