How to Set a Windows Sleep Timer
In this article
- Using the shutdown Command for a One-Time Timer
- How to Tell It Worked
- The One Failure People Hit: Wrong Time Unit
- Setting a Repeating Timer with Task Scheduler
- Worked Example: Sleep in 45 Minutes
- What If You Want a Countdown to Sleep (Not Hibernate)?
- Safety Note: Save Your Work Before Any Timer
- Sleep Timer for a Specific App or Music
- Sleep Timer for Large Batches and Kids
To set a Windows sleep timer, you schedule the computer to shut down or sleep after a set number of seconds using the built-in shutdown command. The command works in every recent Windows version, and the steps below cover the most common method (Command Prompt) and the alternative (Task Scheduler) for a one-time or repeating timer.
Using the shutdown Command for a One-Time Timer
- Press Windows + R to open the Run dialog.
- Type
cmdand press Enter to open Command Prompt. - Type
shutdown /s /t secondsand press Enter. Replace seconds with the number of seconds from now until shutdown. For example,shutdown /s /t 3600shuts down in 1 hour (3600 seconds). - To cancel the timer before it fires, open Command Prompt again and type
shutdown /a, then press Enter.
If you want the computer to sleep instead of shut down, replace /s with /h (hibernate) or use the rundll32.exe powrprof.dll,SetSuspendState 0,1,0 command for sleep. The shutdown command itself does not have a sleep flag, so the sleep command is the reliable way.
How to Tell It Worked
When you run the shutdown command, Windows shows a small notification in the system tray: “You’re about to be signed out” (or similar) with the time remaining. That confirms the timer is armed. When the countdown ends, the computer begins shutting down. If you set a sleep timer, the screen goes blank and the power light blinks or turns off, indicating sleep mode.
The One Failure People Hit: Wrong Time Unit
The most common mistake is entering minutes instead of seconds. The command expects seconds. If you type shutdown /s /t 60, you get 1 minute, not 1 hour. To avoid this, multiply your desired minutes by 60. For a 2-hour timer, use 7200 seconds. If you accidentally set a timer and need to cancel, the /a flag works only while the countdown is still running.
Setting a Repeating Timer with Task Scheduler
For a timer that repeats daily or weekly, use Task Scheduler instead of the command line.
- Press Windows + R, type
taskschd.msc, and press Enter. - In the right-hand pane, click Create Basic Task….
- Name the task (e.g., “Sleep at 11 PM”) and click Next.
- Choose Daily (or your preferred frequency) and click Next.
- Set the start date and time, then click Next.
- Select Start a program and click Next.
- In the Program/script field, type
shutdown. In the Add arguments field, type/s /t 0(or/h /t 0for hibernate). Click Next, then Finish.
The task will run at the scheduled time every day. To change or delete it, open Task Scheduler, find the task in the Active Tasks list, and right-click it to disable or delete.
Worked Example: Sleep in 45 Minutes
Suppose you want the computer to sleep in 45 minutes. 45 minutes × 60 seconds = 2700 seconds. Open Command Prompt and type:
shutdown /h /t 2700
Press Enter. Windows will show a notification that the system will hibernate in 45 minutes. If you meant sleep (not hibernate), use the sleep command instead:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
That command sleeps immediately, so you would need to combine it with a delayed execution tool (see the next section) if you want a countdown.
What If You Want a Countdown to Sleep (Not Hibernate)?
Windows does not have a built-in “sleep after X seconds” command. The shutdown /h command hibernates, which saves your session to disk and powers off. Sleep keeps the RAM powered and wakes faster. For a true sleep timer, you have two options:
- Use Settings > System > Power & sleep to set the “Sleep” time under “When plugged in” (or on battery). This is a system-wide idle timer, not a one-time countdown, but it works if you want the computer to sleep after a period of inactivity.
- Use a third-party utility that can run the sleep command after a delay. Many free tools exist; search for “sleep timer” in the Microsoft Store, but be careful to download only from trusted sources.
If you only need a one-time sleep after a known duration, the hibernate command is the reliable built-in method. It is safe and resumes where you left off.
Safety Note: Save Your Work Before Any Timer
Both shutdown and hibernate close all open programs. Save your documents and close important files before setting a timer, especially if you are leaving the computer unattended. If you are running a long download or render, the timer will interrupt it. For scheduled tasks, you can add a condition to only run when the computer is idle, but that is an advanced setting.
Sleep Timer for a Specific App or Music
If you want music or a video to stop after a set time, use the built-in sleep timer in the app itself. Many media players (like VLC or Windows Media Player) have a sleep timer in their settings. In VLC, go to Playback > Playback Speed or look for the “Sleep” option in the playlist. For YouTube, you can use the browser’s built-in timer or a browser extension. The Windows shutdown command will close everything, not just the media, so it is a blunt tool for that purpose.
Why the shutdown Command Sometimes Shows a Warning
If you run the shutdown command while other users are logged in, Windows may show a warning that they will be signed out. The command still works, but it is polite to warn others if this is a shared computer.
What If the Timer Doesn’t Fire?
Check that your computer is not set to “Never” sleep in power settings, because the shutdown command overrides that, but a sleep timer via Task Scheduler might be blocked by a “wake timers” setting. Go to Control Panel > Power Options > Change plan settings > Change advanced power settings and find “Sleep > Allow wake timers”. Set it to “Enable” for the timer to wake the computer from sleep to run the task.
Sleep Timer for Large Batches and Kids
If you are setting a timer for a child’s computer use, the shutdown command works the same way. You can also use Settings > Accounts > Family & other users to set screen time limits, which is more controlled because it does not shut down the whole computer, only the child’s account. For a single session, the command timer is fine.
Remember that the shutdown command is immediate once the countdown ends. If you need a gentle reminder instead, use the shutdown /s /t command with a longer time, or set a separate alarm in the Clock app.