O'Reilly Network    
 Published on O'Reilly Network (http://www.oreillynet.com/)
 See this if you're having trouble printing code examples


O'Reilly Book Excerpts: Windows XP Hacks

Hacking Windows XP

Related Reading

Windows XP Hacks
100 Industrial-Strength Tips & Tools
By Preston Gralla

by Preston Gralla

Editor's note: Recently, O'Reilly released another book in its new Hacks series: Windows XP Hacks. This book offers power users the kind of know-how to bend Windows XP to their will. And nothing tries the will of a power user more than a desktop slow to start up (or for that matter, shut down). In the first of two hacks we're publishing this week from Windows XP Hacks, author Preston Gralla walks through two steps to take for faster startup times, as well as ways to speed up the shutdown process. And in the second excerpt, Preston talks about some of his favorite ways to hack XP's interface using the Registry. Enjoy.

Hack #3: Speed Up Boot and Shutdown Times

Shorten the time it takes for your desktop to appear when you turn on your PC, and make XP shut down faster as well.

No matter how fast your PC boots, it's not fast enough. Here's a hack to help you get to your desktop more quickly after startup, and to let you walk away faster after shutdown.

The quickest way to speed up boot times is to use the free Microsoft utility BootVis.exe. Although it's intended primarily for developers, anyone can use it to analyze their boot times and see where there are slowdowns. More important, the tool will also automatically make system changes to speed up your boot time, so you don't need to go into a lengthy analysis of where your slowdowns are and how to solve them.

Depending on your system and how it's set up, you may see only a moderately faster startup time, or you may speed up boot time dramatically. I've seen reports of improvements ranging from a little over 3 seconds to more than 35 seconds. The improvements I found on my systems were moderate-7 seconds faster on one, and 10 seconds faster on another. Think of all the things you could accomplish with another 10 seconds in the day!

The BootVis utility traces boot time metrics and then displays the results in a variety of graphs showing total boot time, CPU usage, disk I/O, driver delays, and disk utilization. Download it from www.microsoft.com/whdc/hwdev/platform/performance/fastboot/default.mspx and extract it into its own folder. Go to the folder and double-click on BootVis.exe. To analyze how your system boots, choose Trace → Next Boot. (Choose Trace → Next Boot + Driver Delays if you want to trace delays caused by drivers as well as your normal boot sequences.) Tell the program how many times to reboot and run the test (the more times it runs, the more accurate the results, although the longer the test takes to run). Click OK, and your system will reboot. After you log on after the reboot, you'll see this message:

Please WAIT for Bootvis to launch!

Don't do anything yet; the program is working, even though it doesn't appear to be doing anything. After a while, you will see the screen shown in Figure 1-3. Soon after that the results appear, as shown in Figure 1-4.


Figure 1-3. BootVis alerts you that it is working


Figure 1-4. BootVis activity graphs display how much time each bootup activity takes

A series of graphs outline boot activity and loading time. The Boot Activity graph, shown in Figure 1-4, is the most important and details all aspects of the boot, including how much time each boot activity takes. Hover your mouse over an activity, such as Driver, and a balloon tip will appear, telling how much time that activity takes to load. To see the total boot time, hover your mouse over the rectangle at the top of a solid black line, and your total boot time will be displayed in a balloon tip, as shown in Figure 1-4.

The pictures and graphs are pretty, but the truth is, you don't really need them, because the utility will automatically make changes to speed up your boot time. To have the utility speed up your boot time, choose Trace → Optimize System and click Reboot Now when a prompt appears. Your system will shut down, reboot, give you the same initial prompt as when it's analyzing your system, but then alert you that it's reorganizing your boot files for faster startup. When the alert goes away, you can use your computer as you would normally. If you want to determine your increase in boot speed, run BootVis again and compare the new boot time to your previous boot time.

Enable Quicker Startups with a Boot Defragment

There's another way to speed up XP startup: make your system do a boot defragment, which will put all the boot files next to one another on your hard disk. When boot files are in close proximity to one another, your system will start faster.

On most systems, boot defragment should be enabled by default, but it may not be on yours, or it may have been changed inadvertently. To make sure that boot defragment is enabled on your system, run the Registry Editor [Hack #68 of Windows XP Hacks], and go to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction

Edit the Enable string value to Y if it is not already set to Y. Exit the Registry and reboot. The next time you reboot, you'll do a boot defragment.

WARNING: I've found many web sites recommending a way of speeding up boot times that may in fact slow down the amount of time it takes to boot up, and will probably slow down application launching as well. The tip recommends going to your C:\WINDOWS\Prefetch directory and emptying it every week. Windows uses this directory as a way of speeding up launching applications. It analyzes the files you use during startup and the applications you launch, and creates an index to where those files and applications are located on your hard disk. By using this index, XP can launch files and applications faster. So, by emptying the directory, you are most likely slowing down launching applications. In my tests, I've also found that after emptying the directory, it takes my PC a few seconds longer to get to my desktop after bootup.

Speed Up Shutdown Times

It's not only startup times that you'd like to speed up; you can also make sure that your system shuts down faster. If shutting down XP takes what seems to be an inordinate amount of time, here are a couple of steps you can take to speed up the shutdown process:

Don't have XP clear your paging file at shutdown

For security reasons, you can have XP clear your paging file (pagefile.sys) of its contents whenever you shut down. Your paging file is used to store temporary files and data, but when your system shuts down, information stays in the file. Some people prefer to have the paging file cleared at shutdown, because sensitive information such as unencrypted passwords sometimes ends up in the file. However, clearing the paging file can slow shutdown times significantly, so if extreme security isn't a high priority, you might not want to clear it. To shut down XP without clearing your paging file, run the Registry Editor and go to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management

Change the value of ClearPageFileAtShutdown to 0. Close the Registry and restart your computer. Whenever you turn off XP from now on, the paging file won't be cleared, and you should be able to shut down more quickly.

Turn off unnecessary services

Services take time to shut down, so the fewer you run, the faster you can shut down. For information on how to shut them down, see [Hack #4].

Hack #16: Hacking Your Way Through the Interface

Use Registry hacks to make a grab-bag of great interface changes.

Hidden in the mazes of the Registry are countless ways to hack XP's interface. Here are some of my favorites.

Hide All Icons in the Notification Area

The System Tray, also called the Notification Area, is the small area on the far-right side of the Taskbar, in which utilities and programs that run in the background, such as antivirus software, show their icons.

I don't find it a particularly intelligent use of screen real estate, so I'd prefer not to see the icons there. To hide them, run the Registry Editor [Hack #68] and go to HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer. Among other things, this key controls the display of objects throughout XP. Create a new DWORD called NoTrayItemsDisplay. Assign it a value of 1. (A value of 0 will keep the icons displayed.) Exit the Registry and reboot.

While you're at the HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer key, you can also delete the My Recent Documents icon on the Start menu. Create a new DWORD called NoRecentDocsMenu. Assign it a value of 1. (A value of 0 will keep the icon displayed.) Exit the Registry and reboot.

Hide Only Certain Icons in the Notification Area

You might like to display some icons in the notification area but hide others. If so, you can hide icons on a case-by-case basis. You'll do it by delving through menus, though, not by hacking the Registry. Right-click on the Taskbar and choose Properties → Taskbar. The Taskbar and Start Menu Properties dialog box appears. This dialog box, as the name implies, lets you control how the Taskbar and Start Menu look and function.

In the Notification area of the dialog box, check the box next to "Hide inactive icons," then click Customize. The Customize Notifications dialog box appears, as shown in Figure 2-15.


Figure 2-15. Hiding inactive icons

Click on the program's listing in the Behavior column, and choose from the drop-down menu to hide the icon when the program is inactive, always hide it, or never hide it. Click OK twice. Your changes will take immediate effect.

Add Specific Folders to the Open Dialog Box

When you use certain Windows applications (such as Notepad) to open a file, on the left side of the Open dialog box are a group of icons and folders (such as My Documents, My Recent Documents, Desktop, My Computer, and My Network) to which you can navigate to open files.

Good idea, bad implementation. Do you really keep documents in My Computer? Unlikely, at best. It would be much more helpful if you could list only those folders that you use, and if you could choose to put any folder there, not just ones XP decides you need.

In fact, you can do it, with a Registry hack. It'll let you put just the folders of your choosing on the left side of the Open dialog box. Note that when you do this, it will affect XP applications such as Notepad and Paint that use the Open and Save common dialog boxes. However, it won't affect Microsoft Office applications and other applications that don't use the common dialog boxes.

TIP: If you want to change the dialog "frequently used" folders for Microsoft Word, try Woody Leonhard's Place Bar Customizer, one of many useful utilities from http://www.wopr.com/.

Run the Registry Editor and go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\comdlg32. This is the key that determines how common dialog boxes are handled. You're going to create a subkey that will create a customized location for the folders, and then give that subkey a series of values, each of which will define a folder location.

To start, create a new subkey underneath HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\comdlg32 called Placesbar, and create a String value for it named Place0. Give Place0 a value of the topmost folder that you want to appear on the Open dialog box-e.g., C:\Projects.

Next, create another String value for Placesbar called Place1. Give it a value of the second folder that you want to appear on the Open dialog box. You can put up to five icons on the Open dialog box, so create new String values up to Place4 and give them values as outlined in the previous steps. When you're done, exit the Registry. You won't have to reboot for the changes to take effect. Figure 2-16 shows an example of an Open dialog box customized this way.


Figure 2-16. A customized Open dialog box

If you want no folders to appear in common open dialog boxes, you can do that as well. In HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\comdlg32 create a new DWORD value called NoPlacesBar and give it a value of 1. Exit the Registry. If you want the folders back, either delete NoPlacesBar or give it a value of 0.

Turn Off System Beeps

To me, system beeps that my PC makes when it encounters certain system errors are like balloon tips-gnat-like annoyances that I can do without. So I turn them off using a Registry hack. Run the Registry Editor, go to HKEY_CURRENT_USER\Control Panel\Sound, and find the Beep and ExtendedSounds String values. Set each value to No. Exit the Registry and reboot. The beeps will no longer sound.

Use Your Own Graphic for Your User Account

This one isn't a Registry hack, but I couldn't resist putting it in here since it's one of the more useful ways to customize the interface. The Windows XP graphic for your user account on the Start Menu may not be to your taste, and your choice of other graphics to display there isn't particularly inspiring, either. After all, not everyone wants to be pictured as a rubber ducky, a snowflake, or a pair of horses.

But you're not limited to XP-supplied pictures for your user account: you can use any picture in .gif, .jpg, .png, or .bmp format. In this hack, I'll show you how to use your own picture.

To change your User Account picture to any one that you want, from Control Panel choose User Accounts, then pick the account you want to change and choose "Change my picture" → "Browse for more pictures." Navigate to the picture you want to use and click on OK. Figure 2-17 shows the screen you'll use to change your picture; it also shows the customized User Account picture I use during the winter holiday season.


Figure 2-17. Changing your User Account picture

If you have a digital camera or scanner attached to your PC, a button will show up on the screen shown in Figure 2-17 that lets you take a picture with the camera, or scan a picture with the scanner, and then immediately use that picture for your user account.

For those interested in saving keystrokes, there's a quicker way to get to the screen letting you customize your picture. From the Windows XP-style Start menu, click on your picture, and the screen appears.

Check back to this space next week for hacks on improving the Context Menu, surfing anonymously (without a trace), and tweaking DNS settings for faster Internet access.

Preston Gralla is the author of Windows Vista in a Nutshell, the Windows Vista Pocket Reference, and is the editor of WindowsDevCenter.com. He is also the author of Internet Annoyances, PC Pest Control, Windows XP Power Hound, and Windows XP Hacks, Second Edition, and co-author of Windows XP Cookbook. He has written more than 30 other books.


Return to the O'Reilly Network.

Copyright © 2009 O'Reilly Media, Inc.