Changing the Windows XP Registry without Getting Burned

Technique

Save Time By
Getting in and out of the Registry without breaking anything
Knowing when tweaking the Registry is a waste of time (Answer: usually)
Making a few changes . . . just for practice, right?
The Registry is a big, dark spooky place full of peril and hidden pitfalls. Kind of like, oh, Form 1040. If you aren’t very, very careful, you can bring Windows crashing down, and you’ll never get it to work again — ever. Click once in the wrong place, and your machine freezes so tight you have to send it back to Boise.
At least, that’s what some people think. Personally, I think of the Registry as a big time sink. But scary?
Sure, you have to be careful, but if you don’t go around changing everything in sight, you can dive into the Registry and come back unscathed.
This technique shows you how.

Don’t Mess With This?

The Registry is Windows’ central repository for all sorts of different settings — the name of your keyboard driver, the size of your desktop, the location of the program that plays MP3 files, and tens of thousands more.
Nobody understands the Registry. Not completely, anyway. Nobody has ever pulled together a complete description of what all those settings mean. The items are infuriatingly inconsistent, generally entirely undocumented, and stored away in a very nearly random order.

But these items control Windows.

Once upon a time, you had to be able to edit the Registry if you ever hoped to get Windows working efficiently. (Indeed, I would argue, working at all.) Those times have passed. Nowadays, you probably want to go into the Registry for one of three reasons:
You read on the Internet that if you change some Registry setting, your copy of Windows works better or faster or both.
You have a specific problem that Microsoft says can be fixed only by manually changing a Registry setting. Unfortunately, this type of
Registry editing is on the upswing. The MS Knowledge Base is packed with articles that require changes to the Registry.
You have a specific problem that Microsoft doesn’t talk about, but experts know it can be fixed by changing Registry settings anyway. For example, a lot of Registry tweaks force Windows to bypass (what I believe are) senseless security restrictions in Outlook. My favorite quick Registry tweak, which I detail in this technique, involves setting the NumLock key on or off whenever you start your machine. (The NumLock key, which appears on full-size keyboards, controls whether the number pad keys are interpreted as numbers or as directional arrow keys.) There are many others.
No matter how much you feel the temptation, it’s never a good idea to go into the Registry to “fix” something if you don’t know precisely what needs fixing and how. Changing Registry settings willy-nilly to try to fix random problems only lands you in hot water.


Understanding the Registry

The worst part of the Registry isn’t the Registry itself — it’s the lousy terminology. The Windows Registry has grown up in a hodge-podge way, and terms that (arguably) made some sense back in the days of Windows 3.1 don’t mean bologna now. But we’re stuck with them.
Historically, Microsoft has put absolutely no emphasis on maintaining consistency inside the Registry. It’s kind of like a teenager’s closet: You never know what you’ll find in there, and any resemblance to organization is entirely coincidental.
The Windows Registry may look like a file or a database, but it’s really a conglomeration of many different pieces, drawn from several places. You can change some of the entries, but other entries are completely off limits: Your PC generates them, internally, and you can’t do anything to modify them.
The Registry is organized by keys, much as your disk is organized in folders. Just as a folder may have other folders and files inside, Registry keys may have other keys and values inside. Just as Windows Explorer helps you move from a higher-level folder down to a lower-level folder, and down and down before you finally find the file you want, the Registry Editor helps you move from a higher-level key down to a lower-level key, and down and down until you get to the value you seek.
The Registry has five main keys, called high level keys. Confusingly, in different places in Microsoft’s documentation (I told you the terminology was bad, eh?) they’re also called root keys and/or predefined keys. Those five main keys have very long names (see Table 68-1), but the common abbreviations are HKCR, HKCU, HKLM, HKU and HKCC. I use those abbreviations in this technique, rather than the long names, because almost all documentation about the Registry refers to the abbreviations.
Just as you can add or delete folders in Windows Explorer, you can add or delete keys in the Registry Editor. When you delete a folder in Explorer, you delete all the files and folders inside the folder. When you delete a key in the Registry Editor, you delete all the keys and values inside the key.
That’s where the similarities end. You can move a folder in Explorer, but you can’t move a key in the Registry Editor. And when you delete a key in the Registry Editor, there’s no Recycle Bin sitting there helping you recover from your mistakes. After you delete a key, it’s gone — for good.
Almost all the changes you make to the Registry involve modifying values: changing, adding, or deleting values (although once in a very blue moon you may need to add a key). Each value in the Registry has a name and data.
For example, in Figure 68-1, the HKCC\Software\Fonts key contains five values. (The HKCC\Software\Fonts key controls which fonts Windows XP uses when it’s displaying system-level commands.) The name of the second value is FIXEDFON.FON, and its data is vgafix.fon.
Table 68-1: Windows XP’s High Level Keys

Abbreviation Means What It Does What This Means to You
HKCR HKEY_CLASSES_ROOT Associates filename extensions (such as .doc or .exe) with the actions Windows is supposed to take when, for example, you double-click a file. Also associates types of objects (folders, drives) with actions Windows takes when you double-click them. If you double-click an MP3 file and the wrong program shows up, something is messed up in this Registry key. Don’t try to fix the key directly. Use Windows Explorer’s File Name Associations dialog box (see Technique 20).
HKCU HKEY_CURRENT_USER Controls many settings for the currently logged-on user, from the user’s name to his or her desktop background, and tens of thousands of additional Windows entries. You can make very detailed changes to your Windows desktop by editing entries in this key.
HKLM HKEY_LOCAL_MACHINE Thousands of settings that apply to all users, no matter who is logged on to the PC at any given moment. Program settings for all users frequently go in here.
HKU HKEY_USERS A collection of all the HKCU entries for everyone who has ever logged on to the PC, in addition to a special entry called .DEFAULT, which is copied when a new user gets added. This is where you can change desktop settings for all users.
HKCC HKEY_CURRENT_CONFIG A tiny key that describes the current hardware configuration, and a few basic system settings. You can change only a few of these settings, primarily the ones associated with basic system functions.

Inside the HKCC\Software\Fonts key.
• Figure 68-1: Inside the HKCC\Software\Fonts key.
All this would be academic, if it weren’t for the fact that when you create a new value, or change a value, you have to be sure that you use the right data type for the value’s data. If the value’s data is supposed to be a number, and you type in a bunch of characters, you can mess up everything — even, in very rare cases if you’re working with a truly critical key, freeze Windows so tight you have to reinstall it.
That’s why it’s very important that you follow instructions for changing the Registry quite precisely.
Table 68-2 shows you the three most common types of value data that you encounter in the Registry. Make sure you stick to the type of data that the value requires.
The really confounding fact is that the programmers who set up Registry entries usually don’t give a fiddler’s fig about data types; programmers frequently put strings in binary values, for example. The problem comes when you want to change a value by hand. When that happens, you need to conform to the way the programmer set up things originally. Otherwise, the program won’t understand what you’ve done — and may start having conniption fits.
Table 68-2: Common Registry Data Types

Type Description Using This Info to Save Time
String Characters — letters, numbers, weird characters. Anything you can type on the keyboard is fair game. This is the best kind of key because it’s hard to mess up!
DWORD A “double word” 32-bit (4-byte) integer between 0 and 4,294,967,295 in decimal (or hex 00 00 00 00 to FF FF FF FF). When Registry programmers know they’re going to need a small integer, they usually use DWORDs because they’re easy to program. When you type in DWORD data, use only these characters: 0 1 2 3 4 5 6 7 8 9 A B C D E F You don’t really need to understand that an A is ten in hexadecimal, but it doesn’t hurt. Heh heh heh.
Binary Similar to DWORD, but Binary can be any number of bytes long. Throughout the Registry, many strings are stored as Binary data. In many cases, you have to be very, very careful when you change Binary data so that you don’t change its length. Follow your instructions precisely and keep track of the Binary data’s length.

In certain rare instances (such as the odd editing necessary to add line breaks in the logon screen, described in Technique 8), you have to work with the Binary data that sits behind strings. There’s rarely any good reason for it. Be very careful when editing the Binary numbers behind strings. It’s easy to add or lose one number — and throw off the whole string.

Backing Up Data the Registry Way

Before you start spelunking through your Registry, you need to back it up. I recommend that you perform not one but two separate backups:
Create a System Restore Point. That way, if the wheels fall off and you crash Windows utterly and completely, you can restore the Registry to the point you were at before you started fiddling around (or use the Last Known Good Configuration option on the system boot menu, if you can’t get Windows to boot). For details about setting a System Restore Point, see Technique 64.
Back up the Registry key(s) that you expect to change. That’s what this section is about.
If Windows heads south, you save yourself a lot of time if you have decent backups at hand.
The Registry can store keys and values in many different ways, but you really need to be concerned about only two:
.reg file: A text file that contains Registry entries. You can pick a Registry key and have the Registry Editor copy into a text file all the keys and values contained in that particular key. The text file is called a .reg file.
You keep the .reg file as a backup. Restoring from the backup is easy: When you double-click the .reg file, entries in the file overwrite corresponding entries in the Registry. So if you save a .reg file as a backup for a key, mess up something in the key, and then double-click the .reg file, your mistakes get overwritten with the original entries. Very simple.
Hive: A bunch of Registry entries stored as a binary file. (Don’t be intimidated: A hive is just a bunch of keys under a single key. It’s roughly analogous to a folder.) I don’t recommend that you use hives, because you can’t make changes to them by hand, but in some ways, they’re better than .reg files. If you are curious about hives, though, a discussion about referencing hives is at http://support.microsoft.com/7kbicH199190.
I step you through a real-world example, creating a .reg file as a backup for my favorite quick Registry tweak, in the last section of this technique.

Making Changes Safely

Here’s the general approach to making safe changes in the Registry:
1 Create a System Restore Point (see Technique 64).
2. Back up the key that you’re going to change to a .reg file (see the preceding section).
3. Make the changes.
4. If necessary, force Windows to recognize those changes.
Generally, the most reliable way to do that is to log off and then log back on again.
5. Test the changes.
Depending on the kind of change you made, this step can be quite straightforward or very difficult. For example, testing to see whether a Registry tweak speeds up your Internet connection could be iffy at best. On the other hand, testing to see whether a modified desktop setting (say, a new color for your menus) worked could be as simple as looking at your desktop.
6. If the change didn’t do what you wanted it to do, restore the Registry by double-clicking the .reg file that you saved.
7 If something goes very, very wrong, follow the steps in Technique 64 to restore your system to the System Restore Point.

Running My Favorite Quick Registry Tweak

There are very, very few worthwhile Registry tweaks that Tweak UI doesn’t handle faster, easier, and more reliably.
Let me say that a different way.
If you want to tweak your Registry settings based on something you read in a magazine or a topic, or you saw a trick posted on the Internet — chances are very good that Tweak UI can do what you want with a couple of clicks. Check out Technique 5 for details on Tweak UI.
That said, I know of a good, quick timesaving Registry change that Tweak UI doesn’t handle.
Does your computer have a NumLock key? If you have a full-size keyboard, chances are good that the NumLock key sits above the 7 over on the number pad — to the right of the main keyboard. When the NumLock key is “on”, the keys on the number pad act like numbers. When the NumLock key is “off”, the keys on the number pad usually turn into directional arrow keys, possibly with Home/End/PgUp/ PgDown on the four corners.
In theory, the status of each user’s NumLock key is “sticky” — when you log off or turn off your computer, WinXP is supposed to remember how you left your NumLock key and reinstate the setting when you log back on. In some cases that’s great. But there are two potential problems:

Sometimes Windows XP doesn’t remember correctly.

Okay, okay. Maybe I don’t remember correctly. At least, something or someone comes along and changes my NumLock key, and when I restart Windows, it doesn’t come back the way I remember setting it. Hey, I’ve got more important things to think about.
The NumLock key is set “off” when the PC starts. (Because nobody has logged on yet, Windows doesn’t have a NumLock setting to remember, eh?) If you have passwords on your accounts, you might think that you can type numbers on the number pad, but you can’t. At least, some of the time.
In my particular case, I’m just too darn lazy to want to deal with it. I always want Windows to come up with the NumLock key “on” — no matter what happened in a previous lifetime.
Telling Windows that you always want it to start with the NumLock key “on” is easy — all it takes is a little trip to the Registry. Here’s an extra-cautious first-timer’s approach to editing your Registry:
1 Go through Technique 64 and set a System Restore point.
This is the extra-cautious part. Yes, I’m telling you to put on your training wheels. If you have a System Restore Point, even if you change every scary setting in the Registry and your whole world comes crashing down, all you have to do is run a System Restore (or boot with the Last Known Good Configuration), and your old Registry returns.
2. Choose Start Run, type regedit and press Enter. The Registry Editor appears.
3. On the left side, double-click down the tree
until you get to HKEY_USERS\.Default\Control
Panel\Keyboard.
Your screen looks like Figure 68-2.
Navigate to the "Default" settings for all users.
• Figure 68-2: Navigate to the “Default” settings for all users.
4. Click once on Keyboard, on the left, and then choose File Export. Give your .reg backup file a name (say, Original Keyboard Settings for Default User) and click Save.
If you don’t like this change, you can double-click that .reg file any time and return the HKEY_ USERS\.Default\Control Panel\Keyboard Registry entries to their original state.
5. On the right, in the Name column, double-click InitialKeyboardIndicators.
The Registry Editor brings up an Edit String dialog box (see Figure 68-3).
Change InitialKeyboardlndicators to 2.
• Figure 68-3: Change InitialKeyboardlndicators to 2.
6 In the Value Data box, type 2 and click OK.
With that value data changed to 2, Windows knows to turn on the NumLock key every time it starts.
7 If you want to force Windows to turn the NumLock key on every time you log on to the
computer, navigate to HKEY_CURRENT_USER\
Control Panel\Keyboard.
8. Click once on Keyboard, on the left, and then choose File Export. Give this .reg backup file a name (say, Original Keyboard Settings for Me ) and click Save.
9. Double-click InitialKeyboardIndicators, change the Value Data to 2, and click OK.
10. Choose File Exit.
You return to Windows. Next time you start your machine, or the next time you log on, the NumLock key is forced “on.”
If you ever change your mind about Windows’ NumLock key on startup, double-click the Original Keyboard Settings for Default User.reg file, and that Registry key is stored. Similarly, if you want to change your own settings back, double-click the Original Keyboard Settings for Me.reg file.
That’s the long, boring, safe way to make Registry changes. Once you’re familiar with the Editor, you’ll probably dispense with running a System Restore Point, but you should always take a moment to export a .reg file before you make any changes.
There’s a shorthand for all of the work you just did. If you ever wanted to feel way cool, try the jargon. I can normally summarize the ten steps as: Yo, dude. Change HKU\.Default\Control Panel\Keyboard\ InitialKeyboardlndicators and HKCU\Control Panel\Keyboard\InitialKeyboardIndicators to 2.

Next post:

Previous post: