Shutdown, Restart, or Hibernate Your Computer on a Schedule
by gamerguy13 in Circuits > Microsoft
262833 Views, 10 Favorites, 0 Comments
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.
Create a Batch File
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.
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.
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.
Task Properties
In Windows XP and older, open Scheduled Tasks. Right-click your task and open up its properties. Make favorable adjustments in the settings tab.
Notes
-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.