How-To Geek

How to Make Your PC Shut Down at Night (But Only When You’re Not Using It)


It’s good to to power off your PC when you’re not using it, but do you ever forget and leave it on? Here’s how to configure Windows to automatically power down at night, but only if you’re not using the PC at the time.

We really recommend putting your PC to sleep rather than shutting it down as a normal course of action. Sleep and hibernation have both come a long way since the early days of Windows and if you avoid using them because you used to have problems, you might be pleasantly surprised with how well they work now. And if you still have trouble with your PC waking up prematurely, we have some advice for keeping that from happening.

Of course, if you’d really like to shut your PC down automatically instead, we understand. And it isn’t hard to do. You just need to set up a scheduled task with rules to prevent the shut down if you’re up late using the PC.

Click Start, type “task scheduler,” and then click the “Task Scheduler” app.


In the Task Scheduler window, in the “Actions” pane, click “Create Task.”


On the “General” tab of the Create Task window, give the new task whatever name you want. We like putting a “z_” before any user-created tasks just so that they’re easier to find later with a quick alphabetical sort. Select both the “Run whether user is logged on or not” option and “Run with highest privileges” options. On the “Configure for” drop-down, select your version of Windows.


Next, switch to the “Triggers” tab. Click “New” to create a new trigger.


In the New Trigger window, make sure the “Begin the task” dropdown menu is set to “On a schedule.” Set up whatever schedule you like. Here, we’re going with every night at midnight. When you’re done setting up your schedule, click “OK.”


Back in the “Create Task” window, switch over to the “Actions” tab and click “New” to create a new action.


In the “New Action” window, set the “Action” drop-down menu to “Start a program.” Type “shutdown” into the “Program/script” box. In the “Add arguments (optional)” box, type “/S” to have have the task start a basic shutdown command—the same as if you’d clicked the Shut Down button yourself. If you want the command to also force any running applications to close without warning users, type “/S /F” into the “Parameters” box instead. When you’re done, click “OK.”


Back in the “Create Task” window, switch over to the “Conditions” tab. Enable the “Start the task only if the computer is idle for” option and set the timing you’d like. Here, we’re setting the task to kick in only if the computer has been idle for 15 minutes when the shut down time arrives. We’re also setting the task to wait up to one hour for that idle time to happen.

You also have two other options to consider here. Enable the “Stop if the computer ceases to be idle” option to stop the task if you start using your PC. And enable the “Restart if the idle state resumes” to have the task begin measuring idle time again when you stop using your PC. We recommend going ahead and enabling both those options.


Next, switch to the “Settings” tab. Here, you can set your task up so that it will run again every so often if it fails to run successfully. This lets the task shut down your PC if you’re up using it for much longer than you expected to be. Enable the “If the task fails, restart every” option and then set your preferences. Here, we’re having the task restart every thirty minutes and we’re letting it try restarting up to three times. When you’re done, click “OK” to create the task.


Note that you will likely be asked to enter your user account password to finish creating the task. And you can now exit Task Scheduler. From this point on, your PC should shut down automatically at whatever time you scheduled—unless you’re using the PC at that time.

Walter Glenn is a long time computer geek and tech writer. Though he's mostly a Windows and gadget guy, he has a fondness for anything tech. You can follow him on Facebook and Twitter.

  • Published 10/4/10

Comments (28)

  1. Anonymous

    … OR you could just download a program that does it with a few clicks.

  2. John Horne

    I’m going to try it, but how do I remove the task if I don’t like it?

  3. Kalle

    Do I have to be logged as administrator to be able to run this task?

  4. Mike

    Liking this, but I would need an addition: only when you’re not using it AND only when I’m not downloading something.

  5. Srikanth

    I like “shutdown monster”, its so lite, and easy to setup everytime.

  6. Srikanth

    John Horne : Right the task and click “delete”.

    Kalle : All type of users can use Task Scheduler.

  7. Lorenzo

    What if i want it to turn back at the same time everyday? How do i schedule that?

  8. alkolkin

    I use the Task scheduler regularly and one thing is not very clear. What is the definition of idle?

    I ask that because my computer is never idle. When I leave Firefox on, it does something every couple of seconds. My backup software, ShadowProtect Desktop, is monitoring. Other programs use a couple of micro seconds as well.

    Therefore, my apparently stupid question (my terminology) is not so stupid to me. How would your shutdown (or sleep) be affected by these small uses of CPU?

    Geezer Al strikes again!

  9. Nismo19

    @alkolkin – Good point! I was thinking the same thing. Most apps that take a while to do things have a ‘shutdown when complete’ switch, I would just use that or a fixed time shutdown/hibernate.

  10. Nick P

    I kind of do a combination of this and the sleep/hibernate options.

    I have two power settings configured – “All Day On” and “Overnight Sleep”. One keeps everything on, and the other puts everything to sleep if idle for 5 minutes and eventually hibernates.

    Using the cmd “Powercfg /list” I got the GUID for the two power settings and just set up a task to switch to the overnight settings late at night and back to the the all day settings in the morning using the cmd Powercfg /setactive {GUID}.

    Works like a charm.

  11. alkolkin

    Thank you @Nismo19. I use a product called WinBatch that has an enhanced Basic-like language that gives one the ability to check on the cpu cycles that are being used. It could be used to monitor cpu cycles for, let us say, 15 seconds. It could be programmed so if it stays below a threshold then it puts the computer to sleep. If someone want to wake the computer at certain times, that could easily be done using the Task Scheduler. My view is that this article from howtogeek was not accurate, that is why I asked the question about the definition. It is possible, after all, that the Task Manager automatically looks at some threshold. My version of Winbatch enables me to produce compiled or uncompiled programs.

    Yes most programs that do take a long time to run have a shutdown switch. ShadowProtect has something even better. It allows you to run a script afterward and that script could affect an orderly shutdown, sleep or do anything else that the user wants. Some versions of Acronis have a similar capability.

  12. alkolkin

    @Nick P. While what you say is true, the way to keep your electrical bill the lowest is to put your computer to sleep whenever you leave your desk. To have a product do that for you is more likely to have the desired affect. If you are in the corporate world, then security is also a concern, but I know from my IT days, it is VERY difficult to enforce in a large company.

  13. Bill

    The comments about what defines “Idle” have always bothered me too . Like the other comments,
    my CPU always seems to be doing something. Is there a program that shutdowns my computer
    when the MOUSE is idle ( for ex. not moved for 10 minutes ) ?

  14. Lisa

    I too am curious about the definition of “idle”, seems that programs running on the PC keep it in a constant state of use.

    Also, I am running Vista Home Premium and I saw no “parameters” box to enter /s/f. There was an arguements(optional) box, would that be the same?

  15. gggg


  16. alkolkin

    WOW! AllOff is perfect. I was just trying to figure out how to program the computer to do this stuff @Bill, and your recommendation is perfect.

    Thank you so much. Kudos.

    howtogeek I strongly urge you to correct your suggestion and use his utility instead.

  17. ticotexas

    doesn’t work for me. something must be running so that it is not seen as being “idle”

  18. varun

    Like others I have concerns about “idle” – but in the opposite way of most people.

    You see, I’d like my media center to restart in the middle of the night, but only if it’s not recording any programs. If idle simply means no mouse movement, I fully suspect that I’m going to loose parts of recording programs.

    How do I check that it’s not recording?

  19. Jill

    I’ve set this up at home and it works great. But I’d like to know how to set it up on my system at work, which runs WinXP. When I go to the task scheduler, it opens up a wizard and asks which program you want to run. Shutdown is not an option.

  20. Roi

    “Idle” means no MOUSE movements for X minutes. the CPU is being used 24/7 so it would be illogical to count any CPU activity as non-idle.

  21. Kalle
  22. Mohamed Ashraf

    Idle in computer terms means no user interaction such as no mouse, keyboard, or another user controlled peripherals. Eg watching a video is considered idla if you are not using the mouse or keyboard.

    Also I really liked the article I always want to hibernate the pc if I am not using it however I was wondering if there was a way to stop it if I was downloading something. I am thinking if I make a ahk script to move the mouse a little when I download something so that the computer would not be considered idle

  23. blazer2704

    excellent article

    need this coz i sleep and the laptop is on the whole night

    Awesome thanks

  24. Krikor

    how would you do this on windows xp

  25. Shan

    What option in the task wizard do I pick for shutting it down after I manually ask it to install the updates and it installs them?

    p.s. I stopped using the auto updates in Windows 7 after the darn thing rebooted for updates without warning me before I saved a file.

  26. wolfencj

    For XP users. Open the Scheduled Tasks window and right click -> New -> Scheduled Task.
    This will create a new task than you can edit to the specifications above.

  27. Dayle

    The easiest way to do this on ANY windows OS, is to simply go to START > RUN >
    “at 00:00 shutdown -s” (then type this in without speech marks) This is a simple command that will shutdown the pc at 00:00 hours, you can change this value to any time you want within a 24 hour clock so if I wanted to shut it down at 10pm I would type “at 22:00 shutdown -s” , also you can make your pc log off at a certain type or restart to do this you just change the last value (-s) here are the commands
    -s =shutdown
    -r = restart
    -l =log off
    Hope this helps :)

  28. Desmond

    Wish it will be good and finished

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!