Top Nav

Schedule Windows to Sleep and Wake Automatically

Brian has been doing an awesome job of covering several neat things you can do with Windows Task Scheduler. One more: scheduling Windows to wake or sleep automatically at a particular 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 10 AM to 10 PM every day. This was a compromise between waking up 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 just to 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 primary 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.

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 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 a 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 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 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!

39 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…?
    Thanks.

    • 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.
    Damon

  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.

    • Zeust August 23, 2015 at 12:13 pm #

      thanks for this … been looking a long time a way to turn my pc at specific time and finally I can do it … thanks

  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. 🙂

  8. gt April 17, 2015 at 9:37 am #

    So if the computer’s power settings are configured so it will Never go to sleep, is the sleep .bat overwrite that condition?Which is superior, the bat file or the power setting…

  9. Berty April 20, 2015 at 4:29 am #

    I’m really struggling with the settings. I’m trying to get my PC to wake up at 1200, and sleep at 1400, wake up at 1800 and sleep at 2000, wake up at 0000 and sleep at 0200. I only want it to sleep if it has remained idle for a full hour. What I’m getting is the PC waking up on time but then shutting down minutes later because the sleep task from the previous time has kicked in. Any ideas please?

  10. Fred June 9, 2015 at 11:56 am #

    so how can the spell be reverse[powercfg -h off]…….TO TURN IT BACK ON

  11. Georgi July 5, 2015 at 2:35 am #

    Hello i want to do something slight different (with some additions), but I don’t know how to.
    The case is as follows:
    1) I want my computer to go to sleep at 23:59:59 every night.
    2) Because sometimes I am working till very late i want the computer to prompt me with confirmation to got o sleep like (I will go to sleep do you allow me?) with Yes/ No buttons.
    3) If I press Yes it will go to sleep
    4) If I press No it will suspend the task and ask me again in 1 hour
    5) If I don’t press anything for 30s it will go to sleep automatically (like I if I pressed Yes)

    Can you help me for this ?

  12. lily July 16, 2015 at 10:00 am #

    is there a way to schedule a task to shutdown after four hours of logon? in the trigger tab of the scheduler there is to set a date, but im looking for a way to shutdown after four hours of use everyday or everytime it is being used.

    Any suggestions.

    • goodmr.mrgood August 11, 2015 at 12:53 am #

      you could make a batch file with the command:

      shutdown -s -t 14400

      and make task scheduler run it on startup

      (note: the time is expressed in seconds, hence the 14400 which equals to 4 hours)

  13. dashing501 August 5, 2015 at 1:00 pm #

    Hi…Can you please tell me how to set uo above settings for windows 10. My computer was working fine with your directions but since I updated to windows 10, it’s not working. Computer will go sleep as scheduled but it won’t wake up. But wake up task scheduler works fine if I put computer to sleep through start (windows sign on bottom left) button. I am not if it has to do anything with sleep.bat puting computer into hibernation. Any help greatly appreciated. Thanks

    • Chris December 21, 2015 at 11:03 pm #

      I am having this issue too ^^^ hopefully there is an answer??

  14. Bhup January 2, 2016 at 6:42 am #

    I have a similar problem with my Win10 Pro pc too. I have used task scheduler to make my PC go to sleep (not hibernate) at night, which works fine. But I am trying to get my PC to wake itself in the morning, but no luck here. I have enabled wake timers in the Windows Power Options, and selected “wake this computer” in the conditions tab in task scheduler.

    Has anyone managed to make their PC wakeup in the morning using task scheduler in Windows 10? Thank you.

  15. Malachi January 2, 2016 at 10:00 am #

    Yes you can have it wake up from sleep, however it will go to sleep automatically after a minute or less if you’re not logged in… I have something in place that will log in and then lock it so that programs still run, however it goes back to sleep again… Very annoying ‘feature’ since Windows 8 ( so yes, 10 has the same thing).

    • NoSmoke January 9, 2016 at 12:14 pm #

      I have been experimenting (Win 7 system, desktop) with timed wake up and have found I can get a pretty reliable wake from hibernate i.e. computer wakes and stays on, but wake from sleep mode results in a wake but the computer then shuts off (goes back to sleep mode) about 1 min 30 seconds later for some reason. Only difference I have noted is that wake from hibernate turns on the monitor while wake from sleep does not – don’t know if that is relevant at all.

      I BTW have set Power Options setting shutoffs to “Never” (for both sleep & hibernate).

      • Malachi January 9, 2016 at 1:24 pm #

        Interesting… that you have this with Win 7, because I had win 7 before, but didn’t have the issue until I had a win 8 computer. Which would mean that there would be a way around it (since I had it in 7)… I just don’t know how. Thanks for the tip for hibernation though..

        • NoSmoke January 10, 2016 at 8:35 am #

          No prob. Would be interesting to know why wake from sleep goes back to sleep – bug in Windows?

          If I understand this correctly, it is actually the BIOS that does the wake-up as Windows wouldn’t be active, especially if in hibernate mode. If so, I’d also like to know exactly how that works – does Task Scheduler store the wake-up time(s) in the bios and the bios battery keeps some sort of logic going in the bios to perform the wake-up function??

          I’ve also noted BTW that, if in hibernation, the computer AC power can also be turned off and the machine will still wake at the scheduled time as long the AC is restored before that time.

  16. Sohail January 9, 2016 at 8:19 am #

    Hi,

    Above method to schedule window 10 on SLEEP is not working on my PC, is there another solution to schedule sleep?

    thanks.

    • Malachi January 9, 2016 at 1:05 pm #

      What part isn’t working? To run something at a certain time when the computer is asleep?

      • Malachi January 9, 2016 at 1:06 pm #

        Sorry, forgot to mention: I am using windows 10 and my computer wakes up every morning and runs its stuff (… and then goes back to sleep.. issue with win8 and 10 unfortunately..)

        • Sohail January 12, 2016 at 5:58 am #

          Exactly! this method for sleep schedule not working on window 10. Any solution to schedule for sleep?

          thanks.

          • Malachi January 12, 2016 at 11:52 am #

            Do you want it to wake up at a certain time, or to go to sleep at a certain time?

  17. Dashing501 January 10, 2016 at 6:40 am #

    Actually I just downloaded auto wakeup and shut down software from liftoff.com. There is a 30 day free trial. I just couldn’t handle the frustration and bought the software. It works like charm on Windows 10 too.

  18. Dashing501 January 10, 2016 at 6:42 am #

    Sorry it’s actually lifsoft.com

  19. Chris January 12, 2016 at 12:12 pm #

    Doesn’t wake up on Windows 10. Scheduled sleep works fine though. I have wake on lan and all that active too.

    • Ditophon February 22, 2016 at 8:37 am #

      Hey,

      I had the same problem, too. It seems using the sleep-command above disable the RTC which is necessary for the Scheduler (maybe it forces the Computer to go into hibernation even when it’s diabled or something like that)

      My solution was using the PSTools from Microsoft:

      https://technet.microsoft.com/sysinternals/pstools.aspx

      the command for suspend is:

      …/psshutdown.exe -d

  20. PBC Ho February 29, 2016 at 1:25 am #

    I had a problem and want to share with you all the solution. In general tab of the wake task , I selected “Run whether user are log on or log off” and it does not work properly. The computer is waked up but the printing task I assigned is not executed. I have to change to “run only when user is logged on” and it works !

  21. Sandy Rachmad March 16, 2016 at 1:37 am #

    I got this message after I click ok in task scheduler.
    “Task
    User_Feed_Synchronization-{57EEBECF-6D39-4AA7-B7C6-EBDAF4A1A9A}: The task object version is either unsupported or invalid.”
    What should I do?

  22. seanivo March 25, 2016 at 3:54 pm #

    You can use WinSleep to sleep the computer whenever it is not busy, and wake at the end of a scheduled period. molliesoft.com/winsleep

  23. Syed May 2, 2016 at 4:03 pm #

    Hello Sir,

    I need to turn off the monitor’s screen at 1 AM and turn on at 5:30 AM and then login to gmail.

    I got a script to open chrome and login to gmail. However finding it hard to get the info for monitors screen scheduled turn off and on. I hope you could help me with this or atleast guide me how to do this.

    Thank you

  24. Prakash May 27, 2016 at 1:01 am #

    Highly useful. Great work Mate.

Leave a Reply

 

×

Amazon.com Top Deals of the Day! Check Deals