Restarting and Shutting Down Systems from the Command Line
You’ll often find that you need to shut down or restart
systems. One way to do this is to use the Shutdown utility, which can be used to
work with both local and remote systems. Another way to manage system shutdown
or restart is to schedule a shutdown. Here, you can use Schtasks to specify when
shutdown should be run or you can create a script with a list of shutdown
commands for individual systems.
Real World |
Although Windows systems usually start up and shut down
without problems, they can occasionally stop responding during these processes.
If this happens, try to determine the cause. Some of the reasons systems might
stop responding include the following:
|
-
The system is attempting to execute or is running a startup or shutdown script that has not completed or is itself not responding (and in this case, the system might be waiting for the script to time out).
-
A startup initialization file or service may be the cause of the problem and if so, you might need to troubleshoot startup items using the System Configuration Utility (Msconfig). Disabling a service, startup item, or entry in a startup initialization file might also solve the problem.
-
The system may have an antivirus program that is causing the problem. In some cases, the antivirus program may try to scan the floppy disk drive when you try to shut down the system. To resolve this, configure the antivirus software so that it doesn’t scan the floppy drive or other drives with removable media on shutdown. You could also try temporarily disabling or turning off the antivirus program.
-
Improperly configured sound devices can cause startup and shutdown problems. To determine what the possible source is, examine each of these devices in turn. Turn off sound devices and then restart the computer. If the problem clears up, you have to install new drivers for the sound devices you are using or you may have a corrupted Start Windows or Exit Windows sound file.
-
Improperly configured network cards can cause startup and shutdown problems. Try turning off the network adapter and restarting. If that works, you might need to remove and then reinstall the adapter’s driver or obtain a new driver from the manufacturer.
-
Improperly configured video adapter drivers can cause startup and shutdown problems. From another computer, remotely log in and try to roll back the current video drivers to a previous version. If that’s not possible, try uninstalling and then reinstalling the video drivers.
Managing Restart and Shutdown of Local Systems
On a local system, you can manage shutdown and restart using
the following commands:
Shutdown local system:
shutdown /s /t ShutdownDelay /l /f
Restart local system:
shutdown /r /t ShutdownDelay /l /f
Cancel delayed shutdown of local computer:
shutdown /a
where /T ShutdownDelay is used to set the
optional number of seconds to wait before shutdown or restart, /L optionally
logs off the current user immediately, and /F optionally forces running
applications to close without warning users in advance. In this example, the
local system is restarted after a 60-second delay:
shutdown /r /t 60
Best Practices |
In most network environments, system uptime is of the utmost
importance. Systems that are restarting or shutting down aren’t available to
users, which might mean someone won’t be able to finish her work and might get
upset as a result. Rather than shut down systems in the middle of business
hours, consider performing shutdowns before or after normal business hours. But
if you need to shut down a system during business hours, warn users beforehand
if possible, allowing them to save current work and log off the system as
necessary.
|
Managing Restart and Shutdown of Remote Systems
With remote systems, you need to specify the UNC name or IP
address of the system you want to shut down or restart using the /M parameter.
Thus, the basic syntax for shutdown, restart, and cancel delayed shutdown
become
Shutdown remote system:
shutdown /s /t ShutdownDelay /l /f /m \\System
Restart remote system:
shutdown /r /t ShutdownDelay /l /f /m \\System
Cancel delayed shutdown of remote computer:
shutdown /a /m \\System
In this example, MAILER1 is restarted after a 30-second delay:
shutdown /r /t 30 /m \\Mailer1
In this example, the system with the IP address 192.168.1.105 is
restarted immediately and running applications are forced to stop running:
shutdown /r /f /m \\192.168.1.105
Adding Shutdown or Restart Reasons and Comments
In most network environments, it’s a good idea to document
the reasons for shutting down or restarting computers. With unplanned shutdowns,
you can document the shutdown in the computer’s system log by expanding the
syntax to include the following parameters:
/e /c "UnplannedReason" /d MajorCode:MinorCode
where /C “UnplannedReason” sets the detailed
reason (which can be up to 127 characters in length) for the shutdown or
restart, and /D MajorCode:MinorCode sets the reason code
for the shutdown. Reason codes are arbitrary, with valid major codes ranging
from 0 to 255 and valid minor reason codes ranging from 0 to 65,535. Consider
the following example:
shutdown /r /e /m \\Mailer1 /c "System Reset" /d 5:15
In this example, you are restarting MAILER1 and documenting the
reason for the unplanned restart as a “System Reset” using.
With planned shutdowns and restarts, prefix the reason codes with
p: to indicate a planned shutdown, as shown here:
/e /c "PlannedReason" /d p:MajorCode:MinorCode
For instance, consider the following code:
shutdown /r /e /m \\Mailer1 /c "Planned Application Upgrade" /d p:4:2
No comments:
Post a Comment