Top Nav

Schedule Windows to Sleep and Wake Automatically

Brian has been doing an awesome job of covering several groovy things you can do with Windows Task Scheduler. Here’s one more: scheduling Windows to wake or sleep automatically at a certain time. Why would you want to do this? I don’t know about you, but for me, I was using my desktop Windows 7 PC as a file server for some time. Rather than sending wake-on-LAN packets every time I wanted to access a file on my Windows file server, I decided to leave the thing on from 10AM to 10PM everyday. This was a compromise between waking on demand and leaving my computer on 24/7 (sorry, environment).

There are third-party power management programs that do this, many of which come bundled with laptops. But if you are on a plain vanilla Windows desktop, you may want to just go ahead and do it natively. Here’s how:

1. Disable hybrid sleep / hibernation. (Optional, but recommended)

2. Create a script file (.bat) to put your computer to sleep.

3. Create a script file (.bat) to wake your computer.

4. Schedule your computer to sleep and wake at a certain time.


How to Disable Hybrid Sleep / Hibernation in Windows

The first step is to disable hybrid sleep and/or hibernation on your computer. Why would you want to do this?

Hibernate is a power-saving feature that saves your machine’s state (including unsaved documents, program states, etc.) onto your main hard disk instead of onto the RAM (as sleep does). The tradeoff is slower resume time, but less power draw. This is important for laptops with batteries, but not so much for desktops. Hybrid sleep does both—it saves open documents and application states into the memory and the hard disk. This is so you won’t lose anything in case of a power outage.

But the real issue is that sometimes, hybrid sleep / hibernation can interfere with an automated wake script, depending on your configuration. In my case, waking from hibernation from a script only half worked—the computer would turn on, the fans would spin, and I’d get stuck on the “Resuming Windows” screen forever. If you have similar problems, you might just want to disable hibernation / hybrid sleep altogether. Here’s how:

Open a command prompt as an administrator. To do this in Windows 7, click the Start button, type Cmd and then right-click cmd.exe and choose Run as administrator.

wake and sleep automation - cmd.exe elevated


Type powercfg -h off and press Enter.

disable hibernation / hybrid sleep with powercfg

If the command was successful, then you’ll get no error messages.

If you get the error message: “You do not have permission to enable or disable the Hibernate feature.” then re-read the previous step about running cmd.exe as an administrator :-P

Now, like a bear addicted to espresso, your computer will no longer hibernate. It’ll sleep, but it won’t hibernate. Mission accomplished.

For more information on Hibernation vs. Sleep, read this groovy write-up that Austin did on the subject: Understanding Your PC And Devices, Sleep VS. Hibernate [groovyTips]

How to Create a Batch (.bat) File to Put Your Computer to Sleep

The way we’ll put your computer to sleep is by running a script (.bat) that will initiate the sleep command. By using a batch file, you can add other parameters and commands to it later without rejiggering your Windows Task Scheduler task.

To create, sleep batch file open up Notepad and type the following:

Rundll32.exe Powrprof.dll,SetSuspendState Sleep

auto sleep script for windows 7

Click File –> Save As… Under Save as type… choose All files *.* and give your file a name lie sleep.bat (or something else with a .bat extension).

Got it? If not, you can just download the sleep and wake batch files I already created by clicking here.

How to Create a Batch (.bat) File to Wake Your Computer

There isn’t really a command line command to wake your computer. That’s because if you are in a position to be running commands, then your computer is obviously already awake. But what we can do is create a batch file with something arbitrary in it and then tell Windows Task Scheduler that it can wake the computer in order to run it. So, go ahead and make a batch file that does something like “echo Hello!” and then save it as wake.bat.

auto wake script for windows 7

Again, you can also just download our sleep / wake batch files here.

How to Schedule Your Computer to Sleep and Wake at a Certain Time

Now that we have batch files to sleep and wake our computer, all we need to do is tell Windows when to run them.

Run Task Scheduler. The fastest way to get to it is by clicking the Start button and typing Task Scheduler.

task scheduler - sleep wake schedule


Click Action and then Create Task… In the general tab, give it a name like “Sleep.”

create a sleep task in windows task automator

In the Triggers tab, click New…  Set the task up to begin the task “On a schedule” and choose daily and plug-in the time when you want it to run. Click OK.

set sleep time in windows task scheduler

Your trigger will be enabled.

creating a daily sleep schedule in task scheduler

Next, click the Actions tab and click New… Set the action to “Start a program” and browse to your sleep.bat script. Click OK.

start a sleep script with windows task scheduler

Here’s your action:

windows task scheduler with sleep.bat

If you want to prevent the computer from sleeping if programs are running or someone is using the computer, then use the following settings in the Conditions tab:

prevent computer from automatically sleeping in task scheduler

Click OK. You’re done with this part. If you want to test it out, you can add a new trigger that sets it in motion 1 minute from now.


sleep and wake task scheduler

Next, let’s make a Wake task. Click Action  and Create Task…  and name it Wake in the general tab.

 automaticaly wake in task scheduler

Then, create a daily trigger with the time you want to wake your computer.

wake computer at a certain time in task scheduler

Next, go to the Actions tab and make an action to run your wake.bat script.

wake.bat in windows task scheduler

Now, go to the Conditions tab. Here, make sure that the “Wake the computer to run this task” option is checked.

wake the computer to run this task

Click OK. Now, your computer will wake and sleep at the scheduled times. Enjoy!

11 Responses to Schedule Windows to Sleep and Wake Automatically

  1. tiz8x June 28, 2013 at 3:32 am #

    So I Want : wake up at 20:00 then sleep at 03:00 a.m (just for seeding tor)
    Its ok if I do like Your tips
    Sr For My english

  2. chetan September 3, 2013 at 10:06 pm #

    I also want my PC to remain off(sleep) during weekends.
    Is it settable…?

    • Malachi September 1, 2014 at 8:23 am #

      Yes. Instead of “Daily”, pick “Weekly” and select the days you want it to run (mo-fr).

  3. Dave November 27, 2013 at 10:14 pm #

    WAY more complex than it needs to be:

    1) you don’t need a bat file, AT ALL
    2) You just set the Task Scheduler to run shutdown.exe with the appropriate option

    … no batch (.bat file needed).

    I’m not sure why people constantly write batch files. now if you want to do MORE than just the shutdown command (a series of commands before the final shutdown.exe, then this would make more sense)…. Otherwise just reference shutdown.exe in the task scheduler with the slash commands…

    .. that’s the way I do it… my BIOS wakes the my PC an hour before I wake, be if from hibernation or full shut. This gives Superfetch PLENTY of time to cache my hard drives in either case.

    Then TaskScheduler shuts my computer down if I have not used it for a certain time period (which is outside the normal power save profile settings). This is if I go away, out of town, etc, and forget to power down my PC

    • Jake March 6, 2015 at 10:57 am #

      The title of the article is “Schedule Windows to Sleep and Wake Automatically”. Not Shutdown and wake.

  4. Labeeb Ahmad August 2, 2014 at 12:13 am #

    Sir, Is it possible to do this method to put the computer to sleep if a certain battery percentage level reaches ON IDLE COMPUTER, different from low or critical battery action provided by windows 7 or 8.1. Windows does give option to put to sleep after specific time but not specific battery percentage level.

    • Malachi September 1, 2014 at 8:25 am #

      Yes, however, sleep will still use the battery. That’s why the computer will go to hybernation instead… which is recommended then anyway.

  5. Damon Farris September 17, 2014 at 9:11 pm #

    Thanks for this information. I have been trying to get my computer to wake up when my satellite Broadband downloads do not count against the monthly allocation (10 GB)
    Thanks again.

  6. Ryan S. White (sunsetquest) February 10, 2015 at 10:23 pm #

    Another way that also might work:
    1) Open the command prompt
    2) and type:
    timeout 3600 /NOBREAK & Rundll32.exe Powrprof.dll,SetSuspendState Sleep

    • Ryan S. White (sunsetquest) March 6, 2015 at 9:06 pm #

      Not sure why I posted this – I think I meant to reply on another site…. my comment only puts the computer to sleep after X seconds.

      The above article is very nicely done. Thanks for sharing.

  7. Hatsjer March 18, 2015 at 5:12 pm #

    Thank you so much for this! I love to listen to music when falling asleep. Now I don’t need to worry about my laptop being on all night long. :)

Leave a Reply


× Top Deals of the Day Shop Now