This guide shows you how to use the shutdown command and its various switches to shutdown, restart, or logoff local or networked computers from the command prompt, dialog window, or batch file.
What can the shutdown command do?
The shutdown command can be use via the command prompt, the remote shutdown dialog window, or in a batch file. You can logoff, shutdown, or restart a computer with this tool. You can even set the shutdown tool to perform a task at a certain time on certain days and to many computers at one time using a batch file.
This is a good tool to easily shutdown or restart lots of computers on a network at one time. It can also be handy for helpdesk technicians when fixing remote computers.
Shutdown Command via Dialog Window
Typing commands in a DOS window is not what most
computer users want to fool with so I’m going to start by showing you how to use the dialog window to use the shutdown tool.
To open the dialog window click
start, click
run, type
cmd and
press enter. A black DOS looking window will open. Type
shutdown -i and
press enter. A window similar to the one below will popup.
Under
computers type the network name of the computer you want to shutdown, restart, or logoff. In this example I will use
\\yourcomputer. You can use your computer’s name to try the commands on
your computer if you like.
If you don’t know a computers name
right click my computer, select
properties, select the
computer name tab. Your computer name is listed next to
full computer name.
To send these commands to other computers across your network
you need to have administrative privileges on those computers. An easy way to see if you have administrative privileges on a networked computer is to try browsing to it. Click
start, click
run, type
\\yourcomputer (replace yourcomputer with your computer’s name of course) and press enter. If you are able to access the computer you will be able to send shutdown commands to it. If you get asked for a password or it denies access you don’t have administrative privileges and you won’t be able to send shutdown commands to that computer.
In this example I’m going to shutdown computer \\yourcomputer on my network. Before it shuts down it’s going to show a message for 20 seconds.
The first thing you need to do is add which computer you want to shutdown. Click
add and type your computer name in the
add computers box.
You can send the command to
multiple computers by pressing enter after the name of each computer and typing the name of the next computer on the next line. Each computer needs to be on its own line.
Click
OK when you are finished adding the computer(s) you want to send the command to.
Under
what do you want these computers to do: tell it to shutdown, restart, or logoff.
If you want a box to popup on the computer(s) you are sending the command to that lets them know the computer is about to shutdown, restart, or logoff in X many seconds leave
warn users of the action checked off. If you want to change how many seconds to countdown before performing the action you can change that next to
seconds.
You can tell a user on the computer you are about to perform the action on why you are performing that action by typing your message in under
comment.
Click
OK to send the command to the computer(s).
If you get an error when sending the command it will look like the one below.
Shutdown Command via Command Prompt
The shutdown command becomes more flexible and automated when used from the command prompt. To run the shutdown command from the command prompt, go to
start,
run, type
cmd, and
press enter. In the black box (the command prompt) type
shutdown and the switches you want to use with the shutdown command. You have to use at east one switch for the shutdown command to work.
The Switches
The shutdown command has a few options called switches. You can always see them by typing
shutdown -? in the command prompt if you forget any of them.
-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)
Please note: I’ve noticed using a switch with a – sign doesn’t work sometimes. If you are having trouble try using a / in place of – in your switches.
Examples
shutdown –m \\computername –r –f This command will restart the computer named computername and force any programs that might still be running to stop.
shutdown –m \\computername –r –f –c “I’m restarting your computer. Please save your work now.” –t 120 This command will restart the computer named computername, force any programs that might still be running to stop, give to user on that computer a message, and countdown 120 seconds before it restarts.
shutdown –m \\computername –a This command will abort a previous shutdown command that is in progress.
Using a Batch File
You can create a file that performs the shutdown command on many computers at one time.
In this example I’m going to create a batch file that will use the shutdown command to shut down 3 computers on my home network before I go to bed.
Open notepad and type the shutdown command to shut down a computer for each
computer on the network. Make sure each shutdown command is on its own line. An example of what should be typed in notepad is below.
shutdown –m \\computer1 –s
shutdown –m \\computer2 –s
shutdown –m \\computer3 -s
Now I’ll save it as a batch file by going to
file,
save as, change
save as type to
all files, give the file a name ending with
.bat. I named mine
shutdown.bat. Pick the location to save the batch file in and save it.
When you run the batch file it’ll shutdown computer1, 2, and 3 for you.
You can use any combination of shutdown commands in a batch file. I just used the one above as an example.