I manage a few Windows Servers across my VPN… Updating software, OS, and managing backups, etc. And, sometimes when you are installing an update that requires a reboot things can get a little complicated. Especially, if that server has a lot of services running and you are logged in via Remote Desktop. If there a lot of services that have to be shut down, sometimes the server can hang in the process… Cutting your remote session but not finishing the reboot process.
So… enter shutdown.exe. Shutdown.exe is a command line tool that can be used to shutdown and/or reboot local or remote servers. (Granted you have administrative privileges) You can use shutdown.exe two ways. By command line and the Graphic user inteface. If you want to try the command line approach, Shutdown.exe uses the following syntax:
- \\computername: Use this switch to specify the remote computer to shut down. If you omit this parameter, the local computer name is used.
- /l (Note that this is a lowercase “L” character): Use this switch to shut down the local computer
- /a: Use this switch to quit a shutdown operation. You can do this only during the time-out period. If you use this switch, all other parameters are ignored.
- /r: Use this switch to restart the computer instead of fully shutting it down.
- /t:xx: Use this switch to specify the time (in seconds) after which the computer is shut down. The default is 20 seconds.
- “msg“: Use this switch to specify a message during the shutdown process. The maximum number of characters that the message can contain is 127.
- /y: Use this switch to force a “yes” answer to all queries from the computer.
- /c: Use this switch quit all running programs. If you use this switch, Windows forces all programs that are running to quit. The option to save any data that may have changed is ignored. This can result in data loss in any programs for which data is not previously saved.
- To shut down the local computer in two minutes and display a “The computer is shutting down” message, use the following line in a batch file or type it at a command prompt, and then press ENTER:
shutdown /l /t:120 “The computer is shutting down” /y /c
To cancel the shutdown process, type the following line at the command prompt, and then press ENTER:shutdown /l /a /y
- To shut down and restart a remote computer named “Support,” use the following line in a batch file or type it at a command prompt, and then press ENTER:
shutdown \\support /r
- To schedule the local computer to shutdown and restart at 10:00 P.M., type the following line at a command prompt, and then press ENTER:
at 22:00 shutdown /l /r /y /c
- To schedule the local computer to shutdown and restart at 6:00 P.M. every weekday, type the following line at a command prompt, and then press ENTER:
at 18:00 /every:M,T,W,Th,F shutdown /l /r /y /c
Now you can also do the same thing with the Graphic interface. To activate the GUI Open a command prompt and type: shutdown /i you will then be presented with a window that will look like this:
From the dropdown menus you can choose equivalent selection for the command line switches. Using this method to reboot the remote server takes the Remote Desktop out of the active services list and has been a great help in reliably rebooting the remote servers. This is a great help when you cannot get physically to the server Console and perform the reboot. This command line utility is present in Windows XP, Sever 2003, Windows Vista and Windows 7. I’ve not attempted this from a Server 2008 machine yet but, if it is not available there I will update you.
© 2009, Robert Owen. All rights reserved.