How-To

Schedule Windows to Sleep and Wake Automatically

Too lazy to walk into your office and push the ON button every morning? Me too. That’s why I set up Windows Task Scheduler so my computer automatically sleeps and wakes at a certain time. You can, too, with this tutorial.

Brian has been doing an awesome job 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.)

Schedule Windows to Sleep and Wake Automatically

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 like 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, of course, 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 Times

Now that we have batch files to sleep and wake our computer, we need to 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 “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!

62 Comments

62 Comments

  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.

    • Hendra Winata

      February 4, 2019 at 3:52 pm

      The sleep function is for Other purpose for Example we use the PC for LED display In a remote or out of reach location when if you schedule to shutdown and turn the PC back ON, it won’t directly open up the led program neither play the specific advertisement video. The sleep function Helps a lot in term of Power saving and back ON state to do its supposely doing work without having to Run 24/7/365

    • Leonard

      March 18, 2021 at 3:35 am

      One reason is that shutdown.exe is randomly missing from windows installs. Another is that shutdown.exe is commonly a hackware entry point so sometimes its deleted as a protection mechanism. And the final prize winner is that Microsoft has no idea why anyone would want to sleep their computer because electricity is free.

    • Alex

      January 10, 2022 at 9:15 pm

      There is no sleep option in shutdown.exe.

  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

    • Anonymous

      February 23, 2020 at 11:02 pm

      Fred, to reverse this command, go into command prompt as an administrator, and type the following: [powercfg -h on] .
      Instead of “off” at the end of the command, replace it with on. If you turn it back on, you will revert everything the guide says to do.

  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 ?

    • Derek

      July 2, 2017 at 4:30 pm

      Conditions just set “idle for X minutes” to what you want and then retry to however long you might be working (i.e. only sleep if computer is idle for 10 minutes, keep trying to sleep for up to 3 hours past 23:59:59)

  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.

    • Matt

      August 3, 2016 at 1:41 pm

      Win 10 is ruining the Wake-UP.

      Anyone know how to get around this without using pstools?

  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

      • Elias

        June 2, 2016 at 2:05 am

        Thank you Ditophon!
        psshutdown.exe is the solution for me!

        • Nguyen Nhat Minh

          December 23, 2021 at 8:53 am

          Can you please explain further? what exactly I have to type in the batchfile??

  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.

  25. diMitko

    June 19, 2016 at 4:44 pm

    Can someone explain me in detail how to wake up Win 10, because mine doesn’t want to do so.

  26. Matt

    August 3, 2016 at 1:37 pm

    Using Win 10, Dell all-in-one touchscreen PC.

    Sleep.bat works fine.

    Wake.bat does NOT seem to be working, as I have to use the keyboard to wake my PC.

    Any ideas?

    • Tamir

      August 6, 2020 at 3:39 am

      Same here, the task is performed but the display is still in sleep mode..

    • Aaron

      August 28, 2021 at 8:40 pm

      I don’t use the bat files but sleep mode works but it looks like that’s also what’s preventing the computer from coming back from sleep. I had my pc set to sleep at 8am and wake the PC at 10pm. The PC always goes to sleep but it wasn’t waking up from sleep.
      When I manually put the PC to sleep, the wake function works.

  27. robcarbonell

    October 26, 2016 at 4:02 am

    Hello everyone.

    Task scheduler in windows 10 used to wake my computer every 1. For the last few weeks, I noticed that my computer stopped waking up, removing drivers, updating drivers and enabling all features to get this to work again has failed. I spend about 1 or 2 hours per day trying to get task scheduler to work without any luck. This is driving me crazy, I tied out software molliesoft com / winsleep and I can get the computer to turn on perfectly, BTW great software.

    Why do we need to use a 3rd party software to get this to work, did Microsoft break the task scheduler.

    Thank you

    • support

      October 26, 2016 at 1:24 pm

      Thank you for your kind words about WinSleep! My view is that omitted Microsoft functionality is not a problem, but an opportunity for us 3rd party developers…LOL. Actually, WinSleep does lots more than just turn the computer on and off. It shows a complete graphical history of when it was awake/asleep, and the new Sleep Journal shows you WHY your computer woke up.

      – Marvin Hymowech
      MollieSoft

  28. Giorgio

    May 22, 2018 at 7:12 am

    Simple And Perfect!!!
    Thanks a lot!

  29. Ray

    May 31, 2019 at 1:47 pm

    Thanks for sharing excellent tip.

  30. KAT

    May 29, 2020 at 8:16 am

    The thing that worked for me…To wake laptop from sleep, I had to use the ‘SYSTEM’ account, not my own user account, to run the ‘How to Schedule Your Computer to Sleep and Wake at a Certain Times’ batch method process on this page..

    General tab –> Security options section –> ‘When running the task, use the following user account –> click ‘Change User or Group…’ –> in the ‘Enter the object name to select’ field, type SYSTEM, then click ‘Check Names’ –> click OK

  31. happyone

    June 3, 2020 at 3:12 pm

    The argument Rundll32.exe Powrprof.dll,SetSuspendState Sleep did NOT work for me.

    What worked was: rundll32.exe powrprof.dll,SetSuspendState 0,1,0

  32. Tushar

    July 7, 2020 at 11:24 pm

    Thanks a lot, this worked for me.

  33. Tamir

    August 6, 2020 at 3:41 am

    Hi every thing is working great, but when I use wake up the task is performed with a locked screen meaning the display(monitor) does not come up.

    Any idea on how I can force the display to come up as well?

    working on win 10 HP all-in-one

  34. BĂ©la Balogh

    May 26, 2021 at 6:37 am

    Thanks for this simple method! It works great in combination with a remote app and work! (Especially when you need to have a docker in order to run a program like business center and your laptop can’t run the docker app, so you need your desktop PC on even when working remotely.

  35. Bernhard Diener

    May 17, 2023 at 4:50 am

    Folks, does anyone have devices that have problems waking from sleep/hibernation? If so, which?
    We use SmartCards for logon (password logon being forbidden, even) and it is annoying when the Smartcard reader does not wake up (which happens from time to time) and we have to restart the machine.

  36. AlexS

    July 22, 2023 at 6:34 am

    How can i set it do sleep every 15 minutes if the computer is idle. My power settings arnt working due to my headset preventing sleep.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

To Top