Platinum Edition Using Windows NT Server 4

Previous chapterNext chapterContents


Chapter 43

Editing the Registry

Some of the main topics in this chapter are

Many times, you have to rely on the Registry Editor to make changes to the Registry. For example, many of the fixes that you find in Microsoft's Knowledge Base require that you edit the Registry. A lot of suggestions that you find in the Windows NT resource kits also require that you edit the Registry. Thus, the Registry is just one of the many tools available to you for diagnosing and fixing problems.

REGEDT32 is your window into the Windows NT 4.0 Registry. Even though REGEDT32 is very powerful, it's a very simple program. It doesn't have a toolbar, but its menus are fairly straightforward. It displays each root key in its own MDI (multiple document interface) window. Within each window, it displays the organization of the Registry on the left side of the window and the actual data on the right side--not too complicated. You learn about using REGEDT32 in this chapter, including tips for getting around some of the limitations of REGEDT32.


CAUTION: Windows NT Server 4.0 provides an alternative Registry Editor: REGEDIT.EXE. It's identical to the REGEDIT.EXE found in Windows 95. Microsoft recommends that you not use REGEDIT.EXE in NT because it incorrectly handles some of the data types that are unique to the NT Registry (REG_EXPAND_SZ and REG_MULTI_SZ). In NT, you should only use REGEDIT.EXE to search the Registry, which is a capability that REGEDT32.EXE doesn't possess.

Getting Around REGEDT32

REGEDT32 is in the C:\WINNT\System32 folder. The file name is REGEDT32.EXE. Choose Run from the Start menu, type REGEDT32, and click OK. The REGEDT32 window displays. You can also drag REGEDT32.EXE from the C:\WINNT\System32 folder to the Start button to create a shortcut to it.

Figure 43.1 shows you what REGEDT32 looks like when you open it on your desktop window. You see one MDI window for each root key in the Registry. In each window, you see two panes, which REGEDT32 separates by a divider that you can drag left or right to change the size of each pane. The following sections describe the contents of each pane.

Fig. 43.1

The left pane of REGEDT32 works similarly to the left pane of Windows Explorer.

Left Pane: Registry Organization

The left pane of each root key's window shows the organization of that key--the hierarchy. Even though a key is physically stored in multiple hives, REGEDT32 displays the entire key as one logical unit. When you update a key in REGEDT32, it automatically updates the appropriate hive.

The title bar of each window indicates the name of the root key and the computer that contains the Registry you're editing. It contains several subkeys that REGEDT32 represents as folders. Each subkey can contain more subkeys (also represented by folders), and each of those subkeys can contain more subkeys. Double-click a folder that contains a plus sign (+) to open it or double-click a folder that contains a minus sign (-) to close it.

Mouse challenged? You can also use the keystrokes listed in Table 43.1 to move around REGEDT32. These keys are often the quickest way to maneuver because you don't have to stumble around with the mouse, trying to hit those tiny folder icons.

Table 43.1 REGEDT32 Keystrokes

Key Description
Keypad + Expands the selected folder one level
Keypad - Collapses the selected folder one level
Keypad * Expands all levels of the selected folder
[arrowup] Moves up the list one key
[arrowdown] Moves down the list one key
Home Moves to the first key in the list
End Moves to the last key in the list
Page Up Moves up one screen in the list
Page Down Moves down one screen in the list
Tab Moves the highlight to the right pane

Right Pane: Value Entries for Selected Key

The right pane shows the value entries for the key you've selected in the left pane. Each row in the right pane represents a single value entry and looks something like Name : Type : Value. Name is the value entry name, Type is the value entry type (REG_SZ, and so on), and Value is the value entry data. REGEDT32 separates each part with a colon (:). Therefore, Texas : REG_SZ : "Howdy" is a REG_SZ value entry named Texas that contains the word Howdy. Easy stuff.

Within some keys, you'll notice a value entry called (No Name). This shows up as (Default) in REGEDIT. This is a string value entry that represents the default value for that Registry key. All Registry keys contain this value entry, but some keys don't contain any additional value entries. REGEDT32 also doesn't show default value entries that haven't yet been assigned a value. Aside from (No Name), each key can contain zero or more value entries that have both a name and data.


TIP: You can make REGEDT32 read-only so that you can't accidentally mess up any settings while you're getting used to working with REGEDT32. Choose Options, Read Only Mode. Now, REGEDT32 won't enable you to make any changes to the Registry. Choose Options, Read Only Mode again to be able to make changes.

Searching for Keys

When you search the Registry, REGEDT32 looks for keys that match the text you specify. However, you can't use REGEDT32 to search for value entry names or value data, which makes this feature somewhat useless (you'll usually want to search for names and paths in value entries). Here's how to search the Registry for matching keys:

1. Choose View, Find Key. REGEDT32 displays the Find dialog box shown in Figure 43.2.

Fig. 43.2

Make sure that you deselect Match Whole Word Only if you want to find partial matches.

2. Type the text for which you want to search. If you're searching for a number, try both decimal and hexadecimal notation because both formats are common in the Registry.

3. Click Find Next, and REGEDT32 searches for a match. This can sometimes take quite a while--up to a few minutes on slower machines. If REGEDT32 finds a matching key, it selects that key in the left pane.

4. If the result isn't exactly what you had in mind, click Find Next again to repeat the search. When REGEDT32 reaches the bottom of the Registry, it displays a dialog box telling you that it can't find the requested key.

5. Close the Find dialog box.


TIP: If you need to search for value entry names and data, use REGEDIT.EXE.


NOTE: If you select any Registry key in the left pane of a window and press a key on the keyboard, REGEDT32 selects the first Registry key that starts with that character. Press the same key again, and REGEDT32 selects the next Registry key that starts with that character. For example, expand HKEY_CLASSES_ROOT. Then press the period key, and REGEDIT selects .386 if that's the first entry that begins with a period; press b, and REGEDIT selects .bat; press m, and REGEDIT selects .bmp. If you pause between keystrokes, REGEDIT starts your incremental search (a character by character search) over with the next key.

Renaming a Key or Value Entry

In REGEDT32, you can't rename a key or value entry. If you need to rename a key or value entry, use REGEDIT.EXE.

You can, however, work around this limitation. Save a key and its subkeys to a temporary hive, as described in "Saving and Restoring Keys" later in this chapter. Then, you can restore that temporary hive into a new subkey with a different name and remove the original key.

Changing an Entry's Value

As a user, changing a value entry's setting is probably the number one activity you'll do with REGEDT32. You might want to personalize your desktop, for example, or you might need to adjust a TCP/IP setting to work better with your network:

1. Double-click the value entry that you want to modify in the right pane to open the editor. Remember that each value entry can be a REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, or REG_BINARY (see Chapter 42, "Understanding the Registry"). This dialog box will be different, depending on the type of data stored in the value. Figures 43.3, 43.4, 43.5, 43.6, and 43.7 show you what each dialog box looks like.

2. Change the value, and click OK to save your changes.

Fig. 43.3

The String Editor dialog box shows you the original data before you start editing.

Fig. 43.4

Each line in the Multi-String Editor dialog box represents a separate string in REG_MULTI_SZ.

Fig. 43.5

The editor for REG_EXPAND_SZ looks just like the editor for REG_SZ (String Editor).

Fig. 43.6

In the DWORD Editor dialog box, select Decimal if your hexadecimal math is a bit rusty.

Fig. 43.7

In the Binary Editor dialog box, you can use the Windows calculator (in Scientific mode) to convert decimal values to hexadecimal values for use with this dialog box.


TIP: Protect yourself when changing value data. Save to disk the Registry key that you're changing, as described in "Saving and Restoring Keys," later in this chapter. This way, if something goes terribly wrong, you can always restore the original key, as described in the same section.


NOTE: Changes that you make to the Registry might not be reflected immediately in Windows or the programs that are currently running. The only way to make sure is to restart Windows after closing REGEDT32 or restart any affected program.

Creating a New Key or Value Entry

Creating a new key or value entry is harmless--unless, of course, you know for sure that either Windows or another program will use your new key. For example, the Microsoft Knowledge Base might instruct you to create a new Registry key to fix a problem. That's useful. Creating a new key out of thin air is pretty useless, however. To create a new key or value entry, do one of the following, as appropriate:


TIP: To quickly add a value entry, move the highlight to the right pane by pressing Tab and then Insert.

Deleting a Key or Value Entry

Be very careful about deleting keys and value entries from the Registry; if you carelessly delete these, you'll probably prevent Windows from working properly. If you don't know for sure what will happen, or you haven't been instructed to do so, don't do it. If you're sure it's okay to proceed, use these steps:

1. Highlight the key or value entry you want to delete. Make sure that the highlight is on the key or value entry you intend to delete.

2. Press Delete, and REGEDT32 asks you to confirm that you want to delete the item.

3. Click Yes.


TIP: Before deleting a key, save it to disk as described in "Saving and Restoring Keys," later in this chapter. Then, if something goes wrong, you can restore it, as described in the same section.


NOTE: If you mess up badly while working in HKEY_LOCAL_MACHINE\System\CurrentControlSet, you can easily recover your system. Restart the computer, and press the spacebar when you see Press spacebar to invoke Hardware Profile/Last Known Good Menu.

Saving and Restoring Keys

You can save a key, all its subkeys, and all its value entries to disk as a hive. This is a hive separate from the other hives you find in C:\WINNT\System32\Config. Hives you create by saving a key use the same format as the system hives, however. Think of these as a temporary hive. You have to be a member of the Administrators group with Backup permission, though. Saving a key as a hive is very valuable for a number of reasons:

Saving a Key, Its Subkeys, and Value Entries

To save a key as well as all its subkeys and value entries as a hive, use these steps:

1. Select the key that you want to save to a hive in the left pane of a root key's window. REGEDT32 saves all of that key's subkeys and value entries, too.

2. Choose Registry, Save Key from the main menu. REGEDT32 displays the Save Key dialog box, which works exactly like every other Save As dialog box in Windows NT 4.0.

3. Type the name of the hive (preferably without an extension because that's how Windows NT 4.0 likes to see hives) into which you want to save the key, and click Save.

Restoring a Hive into a Key

Restoring a hive into a key replaces all of that key's subkeys and value entries with the contents of the hive. To restore a hive that you saved, as described in the previous section "Saving a Key, Its Subkeys, and Value Entries":

1. Select the key into which you want to restore a hive that you previously saved. The hive replaces the contents of this key.

2. Choose Registry, Restore. REGEDT32 displays the Restore Key dialog box.

3. Select the hive, and click Open.

4. Click Yes to restore the hive.


NOTE: You can't load a REG file created by REGEDIT by using REGEDT32. Likewise, you can't load a file created by REGEDT32 by using REGEDIT. REGEDIT exports keys into text files (REG files), whereas REGEDT32 saves keys in binary files.

Loading and Unloading Hives

Loading a hive is very different from restoring a hive. When you restore a hive, the contents of the hive replace the key in which you restore it. When you load a hive, REGEDT32 loads that hive in its own space. That is, you get a new subkey under HKEY_LOCAL_MACHINE or HKEY_USERS. Loading a hive doesn't replace anything. Like saving and restoring hives, loading hives is very useful for certain purposes. First, you can load a hive from a computer that is working properly so that you can fix the problem. Second, you can load a user's NTUSER.DAT, if he or she isn't logged on to the computer so that you can fix problems or make other changes.

Loading a Hive into a Temporary Workspace

To load or unload a hive, you must have administrator privileges with Restore and Backup permissions. Here's how to proceed:

1. Select either the HKEY_USERS or HKEY_LOCAL_MACHINE window. You can only load hives into one of these two root keys.

2. Choose Registry, Load Hive to access the Load Hive dialog box.

3. Select the hive you want to load, and click Open. REGEDT32 opens another Load Hive dialog box in which you specify the name of the key in the Registry.

4. Type the name of the key into which you want to load the hive, and click OK.

5. Click Yes to load the hive. REGEDT32 creates a new subkey by that name under the root key you chose in Step 1.


NOTE: You can't load a hive that contains a key that Windows NT 4.0 or another program is currently using. For example, if you want to load the System hive from a remote computer, you must first save a copy of that hive to another file. Then, you can load the copy in REGEDT32.

Unloading a Temporary Hive

After you've made any changes you want to the hive you loaded earlier, use these steps to unload it:

1. Choose the hive in the Registry that you want to unload. You can only unload a hive which you loaded using the steps from the previous section.

2. Choose Registry, Unload Hive.

3. Click Yes, and REGEDT32 removes that subkey from the Registry. Any changes you've made, however, are saved to the hive on disk.

Exporting a Key to a Text File

You can export the contents of a Registry key to a readable text file, which makes studying the file easier. Here's how:

1. Select the key that you want to export into a text file.

2. Choose Registry, Save Subtree As. You see the familiar Save As dialog box.

3. Type the name of the text file in which you want to save the key, and click Save.


NOTE: Unlike REGEDIT, however, you can't import the file back into the Registry with REGEDT32.

Figure 43.8 shows what this text file looks like in Notepad. It doesn't use the same format as REGEDIT when it exports a key into a REG file. In fact, REGEDT32 only exports the selected key; it doesn't export any subkeys.

Fig. 43.8

You can save keys such as HKEY_LOCAL_MACHINE\Hardware to a text file, even though you can't save them as a hive.


Previous chapterNext chapterContents


Macmillan Computer Publishing USA

© Copyright, Macmillan Computer Publishing. All rights reserved.