Getting the Most Out of the Shutdown Procedure


Shutdown is usually a relatively uneventful procedure, and most people simply initiate it and then leave their computer to handle the details. (This is particularly true on most newer systems that shut themselves off automatically after Windows XP closes up shop.) But few people know that, similar to the startup, you can also run programs and scripts as part of the shutdown routine. And since performance isn’t as much of an issue as it is with startup, shutdown is a great place to run scripts that perform time-consuming tasks such as deleting files you no longer need. We’ll close this chapter with a look at a few useful techniques that help you take advantage of the Windows XP shutdown procedure.

Using the SHUTDOWN Command

You normally log off, restart, or shut down your computer using the Start, Shut Down command (if logon was through the Classic logon screen) or the Start, Turn Computer Off command (if logon was through the Welcome screen). However, you can get one-click or shortcut-key access to any of these operations by using the SHUTDOWN command-line utility:

SHUTDOWN [-I | -L | -S | -R | -A] [-F] [-M \\computername] [-T xx]  [-C "comment"] [-D [U] [P]:xx:yy]

I

Displays the Remote Shutdown Dialog, which enables you to set the SHUTDOWN parameters using a GUI interface. If you use this, it must be the first switch after the command.

L

Logs off (note that you can’t use this with the M switch).

S

Shuts down the computer.

R

Restarts the computer.

A

Aborts a pending shutdown.

M \\computername 

Shuts down, restarts, or aborts the remote computer given by computername.

T xx 

Sets timeout for the shutdown to xx seconds. The default is 30 seconds when the parameter is part of the SHUTDOWN command. When the –I parameter is used in the SHUTDOWN command to open the System Shutdown dialog box, the timeout default is 20 seconds.

C "comment"

Specifies the shutdown comment that appears while the shutdown is pending (you can enter a maximum of 127 characters).

F

Forces all running applications to close without warning.

D [U][P]:xx:yy 

Specifies the reason code for the shutdown, where U is an unplanned shutdown and P is a planned shutdown code. For either case, xx is the major reason code (a positive integer less than 256, and yy is the minor reason code (a positive integer less than 65536).

For example, to restart the computer in 60 seconds, you can create a shortcut or batch file that runs the following command:

SHUTDOWN -R -T 60 -C “The system is about to reboot.”

When you run the SHUTDOWN command, the System Shutdown dialog box appears with a warning that the system is about to shut down. If you include a comment, it appears in the Message box, as shown in Figure 4-2.


Figure 4-2: The System Shutdown dialog box appears when you run the SHUTDOWN command.

Deleting Files at Shutdown

If you work with sensitive or private data on your computer, it’s a good idea to delete the telltale traces of your work that Windows XP leaves lying around when you shut down the system for the day.

For example, Windows XP uses a paging file to store data in virtual memory as you work. To keep that data secure and private, you should have Windows XP delete the paging file at shutdown. You can do this via the Group Policy snap-in by opening the Computer Configuration, Windows Settings, Security Settings, Local Policies, Security Options branch. In the Policy list, choose the Shutdown: Clear Virtual Memory Pagefile item. Note that this is equivalent to changing the value of the following registry setting to 1:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management \ClearPageFileAtShutdown 

You can also automatically clear the Start menu’s My Recent Documents list at shutdown. To do this, open the Group Policy snap-in, and display the User Configuration, Administrative Templates, Start Menu And Taskbar branch. There are two policies to work with here:

  • Clear History Of Recently Opened Documents On Exit Enable this policy to clear the My Recent Documents list at shutdown. This is equivalent to setting the following registry value to 1:

    HKCU\Software\Microsoft\Windows\CurrentVersion \Group Policy Objects\LocalUser\Software\Microsoft\Windows \CurrentVersion\Policies\Explorer\ClearRecentDocsOnExit
  • Do Not Keep History Of Recently Opened Documents Enable this policy to prevent Windows XP from tracking recently used documents altogether. This is equivalent to setting the following registry value to 1:

    HKCU\Software\Microsoft\Windows\CurrentVersion \Group Policy Objects\LocalUser\Software\Microsoft\Windows \CurrentVersion\Policies\Explorer\NoRecentDocsHistory

Running Scripts at Logoff or Shutdown

In the same way that you can run scripts when you start the computer or log on, you can also run scripts when you log off or shut down the computer. The Group Policy snap-in enables you to perform this task at two places:

  • Computer Configuration, Windows Settings, Scripts (Startup/ Shutdown) Use the Shutdown item to specify one or more script files to run each time the computer shuts down. Note that if you specify two or more scripts, Windows XP runs them synchronously. That is, Windows XP runs the first script, waits for it to finish, runs the second script, waits for it to finish, and so on.

  • User Configuration, Windows Settings, Scripts (Logon/Logoff) Use the Logoff item to specify one or more script files to run each time any user logs off. Logoff scripts are run asynchronously.




Insider Power Techniques for Microsoft Windows XP
Insider Power Techniques for Microsoft Windows XP (Bpg-Other)
ISBN: 0735618968
EAN: 2147483647
Year: 2005
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net