Editing the Registry

In Regedit, assuming that a key or value's permissions don't prevent it, you can add, delete, and rename keys and values. You can also change most values.

As you'd suspect, there's more than one way to do just about anything in Regedit. You'll find three different ways to change a value: through the main menu, through the shortcut menu, or with a keyboard shortcut. Use whichever method is right for you, but I prefer keyboard shortcuts because I deplore touching the desktop rodent without a reason. You can edit any value by selecting it and pressing Enter.

The following sections describe the features that Regedit provides for editing the registry. These are the basic steps that you'll rely on throughout this book.

Changing Values

I promise that 99.999 percent of the time (had to get the five 9s in there), when working with Regedit, you're going to double-click a value to change it. That's not going to stop me from telling you about other ways you can change a value, however. One way to change a value is to click Edit, Modify. Another way is to right-click the value and then click Modify on the shortcut menu.

Regedit displays a different editor depending on the value's type. For example, Regedit opens the Edit String dialog box when you edit a REG_SZ value. It displays the Edit DWORD Value dialog box when you edit a REG_DWORD value. Unlike the version of Regedit that comes with Windows 2000, the version in Windows XP doesn't toss you into the Edit Binary Value dialog box for values such as REG_MULTI_SZ. This version has dialog boxes for almost all the value types that Windows XP supports. The following graphics show what the different editors look like, with a description of each.

Use the Edit String dialog box to edit REG_SZ and REG_EXPAND_SZ values. Enclosing the value in quotes isn't necessary unless you intend to include the quotes in your value. You can copy values from this dialog box to the clipboard, which is a nifty way to get values into scripts and documents.

click to expand

Use the Edit DWORD Value dialog box to edit REG_DWORD values. By default, you're editing a hexadecimal value, but you won't include any prefixes such as 0x in the value; you just type the hexadecimal digits. You can edit the value as a decimal number by selecting the Decimal option. Note that Regedit displays REG_DWORD values in the Value Data box using both notations.

Use the Edit Binary Value dialog box to edit REG_BINARY values. The first column of numbers in this dialog box is the offset, starting from zero. The second column of numbers contains the binary string in hexadecimal notation. The last column shows the text representation of the binary string. You can edit either the second or third columns. You can type hexadecimal digits or plain text.

click to expand

Use the Edit Multi-String dialog box to edit REG_MULTI_SZ values. Each string is on its own line with no blank lines.

To change a value, click Edit, Modify, and then type the value's new data in the Value Data box. When you change a value using Regedit, the editor immediately applies that change to the registry, but that doesn't mean Windows XP or other programs have noticed the change. In fact, all changes go unnoticed until the program or operating system has a reason to load or reload that value from the registry. For example, if you change the Windows Explorer settings in the registry, open windows won't reflect those changes—you must close and reopen those windows. If you customize Microsoft Office XP, you must shut down and restart it before it'll recognize your changes. Settings that Windows XP loads only when you log on to the operating system and per-user settings, such as the location of shell folders like Favorites, require you to log off and back on to Windows XP for your changes to be reflected. Likewise, settings in HKLM and per-machine settings often require you to restart the computer in order for Windows XP to recognize them because the operating system loads those settings only as it starts.

Chances are pretty good that you're going to mess up something. Unless you have access to a test lab, you're likely to experiment on your production computer (read production as essential). If things get out of hand, don't panic, and by all means, don't make things worse by restarting your computer over and over again or whacking away at the registry until there's nothing left. Instead, see Chapter 3, "Backing up the Registry" to learn how to easily recover your recent working configuration.

start sidebar
Stupid Clipboard Tricks

If you're writing scripts, documentation, deployment plans, and so on, you'll be typing a lot of key names and values. This is an error-prone and painful process, and it's one that you can do much easier using the clipboard.

For instance, instead of trying to type a fully qualified key name, flipping back and forth between Regedit and your text editor, and trying to remember each subkey in the branch, just copy the key name to the clipboard and then paste it in to your document: In the key pane, right-click a key, and then click Copy Key Name.

You can copy value names and data to the clipboard, too. Value names don't tend to be long, but using the clipboard is the only way to ensure you have the value's data correct. In the value pane, right-click the value whose name you want to copy to the clipboard, and click Rename. Press Ctrl+C to copy the name to the clipboard, and then press Esc so that you don't accidentally change the name. If you prefer a less risky way to copy a value's name, edit the value, select the value's name, and then press Ctrl+C to copy it to the clipboard.

Copying a value's data to the clipboard is useful and easy: Edit the value, select the value's data, and then press Ctrl+C to copy it to the clipboard. This is a great way to back up data before changing it. Before changing a value, copy its data to the clipboard, create a new value of the same type, and paste the data on the clipboard into it. For example, if I wanted to change a REG_SZ value called Stubpath, I'd copy its data to the clipboard and then paste that data into a new REG_SZ value called StubpathBackup. Then, if the change doesn't work out, I could restore the original value and repair the problem that I created with my willy-nilly edits.

end sidebar

Adding Keys or Values

The only reason you would create keys and values is if you were instructed to do so; that is, you know adding the value will have some effect. For example, Microsoft's Knowledge Base often instructs you to add a value that fixes a certain problem. Throughout this book, you learn about values you can add to the registry that customize Windows XP. Otherwise, adding a value that no program reads doesn't accomplish anything. If you're itching to add something to the registry, take a look at some of the tips in Chapter 4, "Hacking the Registry," or Chapter 15, "Working Around IT Problems."

To create a new key, first click the key under which you want to create a subkey; click Edit, New, and Key; and then type a name for the new key. When you create a new key, Regedit names it New Key #N, where N is an incremental number beginning with 1, and then selects the name so you can change it.

Creating a new value is similar:

  1. In the Key pane, click the key in which you want to add a value.

  2. On the Edit menu, click New, and then click the type of value you want to create: String Value, Binary Value, DWORD Value, Multi-String Value, or Expandable String Value.

  3. Type a name for the new value.

Regedit names the new value New Value #N and then selects it so you can type a new name. Windows XP requires all names contained in a key to be unique. No two subkeys can have the same name and no two values can have the same name. That's why Regedit names new values New Value #1, New Value #2, and so on. The default data for binary values is null, or no value whatsoever. The default value for strings is the empty string. The default value for REG_DWORD values is 0. After you create a new value, you edit it to change its value from the default.

Deleting Keys or Values

Click the key or value that you want to delete, and then click Edit, Delete. I don't delete settings often, but there are a few circumstances that recur. The first is when I want to reset a program's settings. For example, to reset Regedit's view settings, you must remove the value that contains them. You can wipe out most programs' settings by wiping them out of the registry. You just have to know where to look: the branch Software\Company\Program\Version, under HKCU and HKLM. Although this works well for programs that re-create missing settings, it doesn't work for programs that fall over dead when their settings are missing.

Another circumstance is when I want to tidy up the registry a bit. Often, the registry contains references to files that don't exist (orphans) or settings that just shouldn't be in the registry anymore, particularly after removing a program. With a little thought and a little luck, you can clean these settings out of the registry. Chapter 3, "Backing up the Registry," is a helpful resource for either scenario.

Tip 

There's a better, safer way to remove keys and values than just paving over them. You can rename settings you want to remove, which hides them from any code that's looking for them. Just add your initials to the beginning of the key or value's name. For example, I can hide a value called Session by renaming it JH-Session. Then if something goes terribly wrong, (and it happens from time to time when digging around in the registry), I can remove the current version of Session and give the old version its original name.

Renaming Keys or Values

In Regedit, you can't click a selected file to rename it like you can in Windows Explorer. Instead, you click the key or value that you want to rename, and then click Rename on the Edit menu. You can also click the key or value you want to rename, and then press F2.

In the previous section, "Deleting Keys and Values," you learned that one of the main reasons I rename keys and values is to hide them from Windows XP and other programs instead of permanently deleting them. Then, only after I'm happy with the result, I permanently remove the item. Sometimes I don't even bother to do that, as renamed keys serve as good documentation for the changes I make in the registry. To rename a key or value, select the key, click Edit, Rename, and type a new name.



Microsoft Windows XP Registry Guide
Microsoft Windows XP Registry Guide (Bpg-Other)
ISBN: 0735617880
EAN: 2147483647
Year: 2005
Pages: 185

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