Editing the Registry


Editing the Registry

In Regedit, assuming that a key's or a 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 mouse 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, when working with Regedit, you will double-click a value to change it. There are other ways you can change a value, however. One way 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 and Windows Server 2003 doesn't make you use 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 supports. The following graphics show what the different editors look like, with a description of each.

You use the Edit String dialog box to edit REG_SZ and REG_EXPAND_SZ values. Enclosing the value in quotation marks isn't necessary unless you intend to include the quotation marks in your value. You can copy values from this dialog box to the Clipboard and then paste them into scripts and documents.

graphic

You 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. Select the Decimal option to edit the value as a decimal number. Notice that Regedit displays REG_DWORD values in the Value Data box using both hexadecimal and decimal notations.

graphic

You 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 column. You can type hexadecimal digits in the second column or plain text in the third.

graphic

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

graphic

To change a value, click Edit, Modify, and then type the value's new data into 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 or other programs have incorporated the change. In fact, no changes are incorporated 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 2003 Editions, you must shut down and restart it before it'll recognize your changes. Settings that Windows loads are applied 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 for your changes to be reflected. Likewise, settings in HKLM and per-machine settings often require you to restart the computer for Windows to recognize those changes because the operating system loads those settings only as it starts.

Chances are good that you're going to make mistakes. Unless you have access to a test lab, you're likely to experiment on your production computer. (Read “production” as “essential.”) An alternative is to use Microsoft Virtual PC for testing. If things get unmanageable, don't panic, and by all means, don't make things worse by restarting your computer over and over again or editing 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.

More Info
For more information on Virtual PC, see http://www.microsoft.com/virtualpc.

Clipboard Tricks

If you're writing scripts, documentation, or deployment plans, 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 more easily using the Clipboard.

For example, 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 into 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 then paste the data from the Clipboard into the new value. 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 didn't work out, I could restore the original value and repair the problem that I created with my edits.

Adding Keys or Values

You would create keys and values only if you were instructed to do so—that is, if you know adding the value will have some effect. For example, the Microsoft 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. Otherwise, adding a value that no program reads does not accomplish anything. If you want to add something to the registry, take a look at some of the tips in Chapter 4, “Hacking the Registry,” or Chapter 18, “Fixing Common 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 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 recurring circumstances in which it's necessary. 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 delete most programs' settings by deleting the settings from the registry. You just have to know where to look: the branch Software\ Company\ Program\ Version, under HKCU and HKLM. Although deleting a program's values works well for programs that re-create missing settings, it's not a solution for programs that don't work when their settings are missing.

Another circumstance in which I delete settings is when I want to tidy up the registry a bit. Often, the registry contains references to files that don't exist (orphan settings) or settings that just shouldn't be in the registry anymore, particularly after their program has been removed. With a little thought and a little luck, you can clean these settings out of the registry. Chapter 9, “Troubleshooting Problems,” is a helpful resource for either scenario.

TIP
There's a better, safer way to remove keys and values than just deleting 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 as you can do 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 section “Deleting Keys or Values,” you learned that one of the main reasons I rename keys and values is to hide them from Windows 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 a value, select the key, click Edit, Rename, and type a new name.



Microsoft Windows Registry Guide
Microsoft Windows Registry Guide, Second Edition
ISBN: 0735622183
EAN: 2147483647
Year: 2003
Pages: 186

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