Hack 6 Miscellaneous Startup and Shutdown Hacks

figs/expert.giffigs/hack06.gif

A grab bag of ways to customize the way you start up and shut down your system.

There are many small ways that you can control the way you start up and shut down your PC. This grab bag of four hacks shows you the best of them.

1.7.1 Create One-Click Shutdown and Reboot Shortcuts

Turning off or rebooting XP involves a several-step process: click the Start menu, choose Shut Down, and then select Shut Down or Restart. If you want, however, you can exit or reboot much more quickly, by creating a shortcut that enables one-click shutdowns. You can also use the shortcut to customize the shutdown or reboot?for example, by displaying a specific message or automatically shutting down any programs that are running.

First, create a shortcut on your desktop by right-clicking on the desktop, choosing New, and then choosing Shortcut. The Create Shortcut Wizard appears. In the box asking for the location of the shortcut, type shutdown. After you create the shortcut, double-clicking on it will shut down your PC.

But you can do much more with a shutdown shortcut than merely shut down your PC. You can add any combination of several switches to do extra duty, like this:

shutdown -r -t 01 -c "Rebooting your PC"

Double-clicking on that shortcut will reboot your PC after a one-second delay and display the message "Rebooting your PC." The shutdown command includes a variety of switches you can use to customize it. Table 1-3 lists all of them and describes their use.

I use this technique to create two shutdown shortcuts on my desktop?one for turning off my PC, and one for rebooting. Here are the ones I use:

shutdown -s -t 03 -c "See you later!"
shutdown -r -t 03 -c "You can't get rid of me that quickly!"

Table 1-3. Switches you can use with shutdown

Switch

What it does

-s

Shuts down the PC.

-l

Logs off the current user.

-t nn

Indicates the duration of delay, in seconds, before performing the action.

-c "messagetext"

Displays a message in the System Shutdown window. A maximum of 127 characters can be used. The message must be enclosed in quotation marks.

-f

Forces any running applications to shut down.

-r

Reboots the PC.

1.7.2 Automatically Turn On Num Lock, Scroll Lock, and Caps Lock

When you start your PC, Num Lock, Scroll Lock, and Caps Lock don't automatically toggle on. You can automatically turn each of them on or off whenever your PC starts, for all accounts on the PC. As a practical matter, most people probably want to have only Num Lock automatically turned on, but this Registry hack gives you the power to force any combination of keys on or off. Run the Registry Editor [Hack #68] and go to HKEY_USERS\.Default\Control Panel\Keyboard. Find the String value InitialKeyboardIndicators. By default, it is set to 0, which means that Num Lock, Scroll Lock, and Caps Lock are all turned off. Set it to any of the following values, depending on the combination of keys you want turned on or off:

0

Turns off Num Lock, Caps Lock, and Scroll Lock

1

Turns on Caps Lock

2

Turns on Num Lock

3

Turns on Caps Lock and Num Lock

4

Turns on Scroll Lock

5

Turns on Caps Lock and Scroll Lock

6

Turns on Num Lock and Scroll Lock

7

Turns on Caps Lock, Num Lock, and Scroll Lock

Exit the Registry. When you restart, the new setting will take effect.

1.7.3 Stop Error Messages from Displaying on Startup

If you constantly see an error message that you can't get rid of?for example, from a piece of software that didn't uninstall properly and continues to give errors on startup?you can disable it from displaying on startup. Run the Registry Editor and go to HKEY_LOCAL MACHINE\SYSTEM\CurrentControlSet\Control\Windows. (This key holds a variety of Windows system settings, such as the location of your system directory.) Create a new DWORD called NoPopupsOnBoot and give it a value of 1. Exit the Registry and reboot for the setting to take effect. To disable it, either delete the DWORD value or give it a value of 0.

1.7.4 Give More Time for Processes to Close at Shutdown

When you shut down Windows, XP gives each process, service or application 20 seconds to close before the operating system turns off the computer. If the process, service, or application doesn't shut down within 20 seconds, a dialog box appears, prompting you to either wait 20 more seconds, immediately end the process, service, or application, or cancel shutdown.

If this dialog box appears frequently, you may be running an application, service, or process that often takes more than 20 seconds to close. To solve the problem, you can increase the amount of time that XP waits to display the dialog box so that the dialog box will no longer appear. To do so, run the Registry Editor and go to HKEY_CURRENT_USER\Control Panel\Desktop. Look for the String value WaitToKillAppTimeout. Edit the value by entering the amount of time you want XP to wait before displaying the dialog box, in milliseconds. The default is 20000, or 20 seconds. If you want XP to wait 25 seconds, enter the value of 25000. Exit the Registry and reboot.