Shutdown is an interesting command line program found in Windows 7 and
earlier operating systems such as XP. Administrators love testing the shutdown
command
because it has such a dramatic effect - it can down a network computer.
The shutdown executable is available at the command line in Windows 7, Vista, XP and also the Windows Server
family. Once you launch the DOS box by typing cmd, your
first decision is do you want to shutdown
(/s), or reboot (/r) the computer?
Sooner or later everyone makes the mistake of accidentally shutting down
the local machine instead of the target computer that
they really wished to reboot. To recover from this mistake pay close attention to the syntax
of the abort command Shutdown /a.
The default computername is the local machine, for the 'Remote' switch
you need /m. The full command would
be: Shutdown /s /m \\ComputerName. If the slashes look slightly
strange, you could try Shutdwon -s -m \\ComputerName, in this example, 'ComputerName' is the
hostname of the remote
operating system. None of these commands are case sensitive so sHUTDOWN /R /m \\ComputerName
would work just as well.
Note 1: There is no space between the backslashes and the computername \\
ComputerName would not work.
For
testing /m on the local machine, try 127.0.0.1
For example, shutdown /s /m \\127.0.0.1 Such a command is useful in batch files.
Alternatively, to reboot numerous computers try PowerShell's command
Restart-Computer.
Examples
of Shutdown switches
shutdown /s /m \\Laptop - Shuts down, or
stops a remote machine called 'Laptop'
shutdown /r /m \\Laptop -
Reboots a remote machine called 'Laptop
Note 3: For once the sequence of switches is
vital, hence shutdown /m /s \\Laptop does not work.
Encouraging computers to sleep when not in use is a great idea -
until you are away from your desk and need a file on that remote sleeping machine!
Wake-On-LAN really will save you that long walk to awaken a hibernating
machine; however my reason for encouraging you to download this utility is
just because it's so much fun sending those 'Magic Packets'. As Wake-On-LAN (WOL) is free, see
if I am right, and you get a kick from arousing those sleeping machines.
WOL also has business uses for example, wakening machines so that they can have
their patches applied.
/t is for time. Is 30 seconds too short (or too long) a time?
You can adjust with /t: 60 to display the dialog box for one minute. Maximum is
600 seconds.
/f is for force. 'Mr Nasty', is coming - ready or not! Shutdown
/r /f as you may have guessed, restarts the machine, and closes any programs
without warning.
/c is for a comment. Would you like to put your stamp on the shutdown?
Let people know who is in charge, who is shutting them down? /c "Guy
is shutting you down"
/d p:4:1 reason. Personally, I would avoid this switch, the syntax
is tricky the numbers obscure and worst of all it does nothing exciting.
That said the idea is sound, it enters a reason for the shutdown in the
event log. If you activate shutdown's help, then you will get a whole
list of major and minor reasons that you could employ with this switch.
For me, this switch is an option, an option that I do not take.
Consider making a shortcut to shutdown. The advantage is that you can
include the /i (-i) for interactive switch. The benefit is that
you have a GUI to control your shutdowns or restarts.
Just right-click the desktop, New, Shortcut, type Shutdown -i
/i Display the graphical user interface (GUI). This must be the first
option. /l Log off. This cannot be used with /m or /d options. /s
Shutdown the computer. /r Shutdown and restart the computer. /g
Shutdown and restart the computer. After the system is rebooted, restart any
registered applications. /a Abort a system shutdown. This can only be
used during the time-out period. /p Turn off the local computer with no
time-out or warning. Can be used with /d and /f options. /h Hibernate the
local computer. Can be used with the /f option. /e Document the reason
for an unexpected shutdown of a computer. /m \\computer Specify the
target computer. /t xxx Set the time-out period before shutdown to xxx
seconds. The valid range is 0-315360000 (10 years), with a default of 30.
If the timeout period is greater than 0, the /f parameter is implied. /c
"comment" Comment on the reason for the restart or shutdown. Maximum of 512
characters allowed. /f Force running applications to close without
forewarning users. The /f parameter is implied when a value greater than 0
is specified for the /t parameter. /d [p|u:]xx:yy Provide the reason for
the restart or shutdown. p indicates that the restart or shutdown is
planned. u indicates that the reason is user defined. If neither p nor u
is specified the restart or shutdown is unplanned. xx is the major
reason number (positive integer less than 256). yy is the minor reason
number (positive integer less than 65536).
PowerShell v 2.0's Restart-Computer is very similar to the Windows 7 shutdown /r command. A likely scenario is that you wish to
automate the reboot of a or remote server. With a tiny
substitution to the cmdlet's verb you could change the command so that it
simply shuts down the computer.
See more about using
PowerShell's Restart-Computer cmdlet.
How To Stop Psycho Remotely Shutting Down Computers
If you are running a training session and the delegate from hell keeps
shutting down other students machines by abusing shutdown -s or -r, then
configure a policy to prevent 'Force Shutdown From A Remote Machine'.
Launch GPMC or SECPOL.MSC Navigate to Local Policies, User Rights
Assignment.
Experiment by assigning just your account, rather than all
administrators.
Guy
Recommends: The Free Config Generator
SolarWinds' Config Generator is a free tool, which puts you in charge of
controlling changes to network routers and other SNMP devices.
Boost your network performance by activating network device features
you've already paid for.
Guy says that for newbies the biggest benefit of this free tool is that
it will provide the impetus for you to learn more about configuring the SNMP
service with its 'Traps' and 'Communities'.
Summary of Windows 7 Remote Shutdown Command Line
Switches
It's fun to learn the Windows 7 shutdown command line switches, and one day they
will save you a long walk when you want restart or stop a remote computer.
My advice is to perfect the /a (abort) switch, that way you won't panic if
you issue a command to shutdown the local computer instead of the network
machine.
For beginners, shutdown /i gives you time to check the options in a GUI.
If you like this page then please share it with your friends