Introduction: Shutdown, Restart, or Hibernate Your Computer on a Schedule

In this instructable, I will be showing you how to shutdown, restart, or hibernate your computer on a schedule.

See the notice at the end if you are using an older operating system than Windows XP.

Step 1: Create a Batch File

First, you must create a batch file (.bat) to be executed. Open notepad (all programs\ accessories). Type in exactly as I dictate:

For shutdown:

c:\windows\system32\shutdown -s -f -t 00                  (or do ...shutdown -p -f)

For restart:

c:\windows\system32\shutdown -r -t 00

For hibernate:

c:\windows\system32\shutdown /h

Save it anywhere you like as shutdown (or whichever accordingly) .bat so it would be "shutdown.bat" for example.
DO NOT save as a -.bat.txt, you are then merely saving text.

Step 2: Schedule It

In Windows Vista or 7 search "task"; Task Scheduler should be at the top of the list. Open it. Click "create basic task". Type in the name you want to call it and a description if you like. Specify when you want it to start. Specify date, time, and recurrence. Choose an action (start a program). Browse for the batch file. At the end, view over it to make sure it is exactly what you want, and click finish. At the task manager main menu, you will have to refresh the list at the bottom for your new batch file to appear (this is optional, it will take affect either way). It is best for the computer to restart to take affect.

Windows XP users and older with have a slightly different process. See next step.

Step 3: Schedule It for XP and Older

For computers running XP and older, follow these steps. First, open Scheduled Tasks (all programs\accessories\system tools\scheduled tasks). Add Scheduled Task; a wizard comes up. Select the batch file. Choose the conditions under which this task will perform. Give specific date, time, and recurrence. If you use a password enter it. Finish it.

Step 4: Task Properties

These tasks come with pre-programmed settings and conditions that may be unfavorable to some users. For Windows Vista and 7 users, open Task Scheduler. It will typically open the main menu; Task Scheduler (Local), on the top right-hand window. Right below that, click on Task Scheduler Library. Right-click your task and make favorable changes in the general, conditions, and settings tabs.

In Windows XP and older, open Scheduled Tasks. Right-click your task and open up its properties. Make favorable adjustments in the settings tab.

Step 5: Notes

In the batch files:

 -s         indicates that the shutdown application is actually going to shut down the computer

 -f            forces all running programs to close

 -t 00        indicates no delay in execution (this does not apply to the hibernate batch file)

 -r             indicates a restart
 
 /h            indicates hibernation

Also:

 -t xx          timeout period (xx is number of seconds)

 -l              is logoff [L] (can only be used by itself)
 
 -a            is to abort an already initiated sequence

 -i             opens the shutdown GUI

-m \\computername       name of computer that action is applied to (using your computer name is 
                                           same as not putting it in and may be configured to shut down a local 
                                           remote computer though I am not sure how

 -g            restarts computer and any registered applications

 -p            turn off computer with no time-out or warning (same as ..shutdown -s -t 00)

 -e            document reason for unexpected shutdown

 -c "comment"        comment on the action

 -d [p or u]:xx:yy      reason; p indicates it is planned; u indicates it is user defined; xx and yy are 
                                reason ID numbers (u:0:0 is easiest, it means other and unplanned)

All these functions also work in comand prompt (cmd). In cmd, you also do not have type the entire filepath.

Type shutdown in cmd and it will give a list of these variables. Note, not all operating systems will give a complete list, some may not give all the reason ID numbers, some may not have all the variables or may not support them, some may even simply shut down no matter what form of the shutdown command is put in the command line.

When in cmd or making a batch file, doing  more than what I have simply told you requires following a strict syntax. Does NOT include the brackets. (The "or"s also are exempt from it):

shutdown [-i or -l or -s or -r or -g or -a or -p or /h or -e] -f -m \\computername -t xx -d [p or u]:xx:yy -c "comment"

You probably already knew this, but these batch files work under normal conditions, not just as scheduled tasks. Click it like you would any other icon or program to run it in Windows.

Step 6: Notice

For Windows 2000 and Windows NT 4.0 users: shutdown.exe is not already on the computer, you must get it from the resource disc or a computer running Windows XP. You cannot download it from microsoft. Also, for anyone running an operating system older than Windows XP, there is no windows folder, the windows folder replaced the winnt folder in XP. So, it would be c:\winnt\system32\shutdown (if you save it there). You should also be able to transfer it from XP to any older computer such as 95, 98, or ME if it is not already on them.

Comments

author
Padlock made it!(author)2009-10-12

Hmm. You're creating a batch file to run a single command. Unnecessary?

Next time, just try scheduling the task to run shutdown.exe. And the /h (hibernate) switch for shutdown.exe is only compatible with Vista, and maybe Windows 7. Unsure about the latter though.

author
gamerguy13 made it!(author)2009-10-12

Simply running shutdown.exe does not work if you have tried it.

author
Padlock made it!(author)2009-10-12

Uh, it has to work. A batch file is literally a set of programs with specific parameters to run. You are most likely running it without parameters. In the task scheduler, set it up to run shutdown.exe directly; not the batch file. Where it says "Add Arguments" try "/s /t 30" or another parameter; it should work. It has to work.

Shutdown.JPG
author
gamerguy13 made it!(author)2009-10-13

A bonus to batch files are that they can run outside a schedule actually in Windows, though I am not sure what for exactly.

author
Padlock made it!(author)2009-10-14

I am not sure what you are trying to communicate.

A batch file is a list of programs located within the path. A batch filewith a single command is useless because you can simply refer to thecommand directly. Anything you can do with that batch file, you can do without.

author
EthanC70 made it!(author)2016-12-05

I have a use for the single-command batch file. If one wants to run a program with flags, a shortcut to a batch file, with the shortcut icon replaced, is a simple enough solution.

author
gamerguy13 made it!(author)2009-10-13

Then that is another way to do it.

author
seani4 made it!(author)2016-05-01

A more advanced solution is to use a program that allows sleep or hibernate on a schedule, like molliesoft winsleep. It also shows a graph of when the computer was awake or asleep.

author
Pratik+Sonigra made it!(author)2016-04-19

For this and other batch files visit

http://codeitoff.blogspot.in/

author
PetrH12 made it!(author)2016-03-09

See a video about automatically shotdown pc.

https://www.youtube.com/watch?v=jIJZzKLvHwk

author
Gregorid made it!(author)2014-11-07

For those people which do not understand how to implement automatic shutdown actions here is something more simple described step by step so everyone can do it : http://pc-problem-solutions.blogspot.com/2014/02/set-automatic-shutdown-on-your-pc.html

author
DeanGPotts made it!(author)2011-03-22

Hi i have a similar instructable and i use the path %windir%\System32\
which windows should recognise on virtually all versions of windows.

Hope this helps :)

author
nehav made it!(author)2010-03-08

where to put our mobile number from which we are sending shutdown command

author
chosenone3 made it!(author)2009-10-12

Good tutorial ,but windows folder may be on other drive like "D:" :]

author
gamerguy13 made it!(author)2009-10-12

The windows folder is on the drive that the OS is on. If your OS is on the D drive, the filepath would be:

d:\windows\system32\shutdown...

author
chosenone3 made it!(author)2009-10-12

I know but i think there is a way to shutdown a pc using other method (that doesn't need to have path specified)

author
Padlock made it!(author)2009-10-12

A program does not have to have a path specified, as long as it resides in one or more of the directories listed in the %path% variable. To see the path, open command prompt and type echo %path%.

author
gamerguy13 made it!(author)2009-10-13

Doing that with shutdown.exe automatically make it perform an immediate shutdown. It may not always be what someone wants though.

author
Padlock made it!(author)2009-10-14

I'm assuming you had meant to reply to my other comment. This is false. With the "/t xxx" switch you can delay it as long asdesired. It is exactly the same as referring to it inside of a batch file.

author
gamerguy13 made it!(author)2009-10-12

Command prompt does not require typing the entire filepath.

author
lemonie made it!(author)2009-10-12

A lot of tasks that will run while you're in bed have the shutdown option: what are you running on this?
(interested)

L

author
gamerguy13 made it!(author)2009-10-12

?

author
lemonie made it!(author)2009-10-12

Why do you use this or what for?

L

author
gamerguy13 made it!(author)2009-10-13

It could be used for a server. I currently have no use for it but I thought I would just share some knowledge.

author
lemonie made it!(author)2009-10-13

OK.

L

author
uthus made it!(author)2009-10-11

For Linux just edit your cron file:

# To restart daily at say 4 AM:
0 4 * * * reboot  # (or shutdown -r)

# To restart the first day of the month at 4 AM:
0 4 1 * * reboot

# To restart to shutdown at 12:01 AM on New Year's Day:
1 0 1 1 * shutdown

# To restart Monday at 6 AM to be ready for the upcoming workweek:
0 6 * * 1 reboot

# Columns are:
# 1 minutes
# 2 hours
# 3 day of month
# 4 month
# 5 day of week

# for more information `man 5 crontab'

Check this script for hibernating or suspending:
http://www.linux.com/news/hardware/laptops/8253-how-to-suspend-and-hibernate-a-laptop-under-linux

About This Instructable

205,790views

10favorites

License:

Bio: I am an engineering student in the midwest. in my spare time, which become increasingly non-existent, I enjoy cooking, fixing things of mine, and wasting ... More »
More by gamerguy13:Delicious and Light Orange ChickenAs Told By Ginger BarsFix a broken blind with only a broken pen clip and scotch tape
Add instructable to: