The ability to restart a computer either local or remote from the command line is useful in a variety of circumstances.
- When remote desktop into an XP machine only log off and disconnect are the options
- When a remote computer is unresponsive your can sometimes force a reboot.
- Using scheduled tasks and a one line batch file you can reboot in the middle of the night. This is especially useful on servers to minimize downtime.
Syntax
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c “comment”] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c “comment” Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)
Samples
Shutdown -r -t 0
Restart the current computer now (that is zero and in no seconds delay for time). Place this command into a batch file and put it in a scripts folder on servers. Then create a scheduled “one-time” task that can be configured as needed to reboot at a desired time.
Shutdown -r -m \\computername -t 10 -f
Restart a remote computer called computername in 10 seconds. This displays are dialog warning and countdown. Or you could just go with the zero. The -f forces the restart because the reason you probably need this is the computer is not responding the remote desktop or other attempts at access.
Shutdown -i
Gives you a dialog box to select remote or local computer and configure all the options as needed. This includes the ability to search for computers in AD by name.