5. Backing Up Before You Edit
One relatively safe
way to edit your registry is to back up the section you're interested in
before you make any changes to it. If something goes wrong, you can
usually use your backup file to restore the registry to the state it was
in when you backed up.
Registry Editor can save all or portions of your registry in any of the four different formats described here:
The Registration Files option creates a .reg file, a text file that can
be read and edited in Notepad or another similar program. A .reg file
can be merged into the registry of a system running Windows 7, Windows
Vista, Windows XP, or Windows 2000. When you merge a .reg file, its keys
and values replace the corresponding keys and values in the registry.
Using .reg files allows you to edit your registry "off line" and add
your changes to the registry without even opening Registry Editor. You
can also use .reg files as an easy way to share registry settings and
copy them to other computers.
Registry Hive Files
The registry hive format saves a binary image of a selected portion of
the registry. You won't be able to read the resulting file (choose one
of the text-file options if that's what you need to do), but if you need
to restore the keys you've worked on, you can be confident that this
format will do the job correctly.
hive file is the format of choice if you want to create a backup before
working in Registry Editor. That's because when you import
a registry hive file, it restores the entire hive to exactly the way it
was when you saved it. (The .reg file types, when merged, restore all
the saved keys and values to their original locations, which repairs all
deletions and edits. But the process does not remove any keys or values
that you added.) Note, however, that a registry hive
file has the potential to do the greatest damage if you import it to
the wrong key; see the caution in the following section.
Win9x/NT4 Registration Files The Win9x/NT4 Registration Files option also generates a .reg file, but one in an older format used by earlier versions
of Windows. The principal difference between the two formats is that
the current format uses Unicode and the older format does not. Use the
Win9x/NT4 Registration Files option only if you need to replicate a
section of your registry in the registry of an older system.
The Text Files option, like the Registration Files option, creates a
file that can be read in Notepad or another text editor. The principal
advantage of this format is that it cannot accidentally (or
intentionally) be merged into the registry. Thus, it's a good way to
create a record of your registry's state at a particular time. Its
disadvantage, relative to the .]reg file format, is its size. Text files
are considerably larger than corresponding .reg files, and they take
longer to create.
To export a registry hive,
select a key in the left pane, and then on the File menu, click Export.
(Easier yet: right-click a key and click Export.) In the Save As Type
list in the Export Registry File dialog box, select one of the four file
types. Under Export Range, select Selected Branch. The resulting file
includes the selected key and all its subkeys and values.
5.1. Restoring the Registry from an Exported Hive
If you need to restore the
exported hive from a registry hive file, select the same key in the
left pane of the Registry Editor window, click Import on the File menu,
and specify the file. You'll see a confirmation prompt letting you know
that your action will overwrite (replace) the current key and all its
subkeys. This is your last chance to make sure you're importing the hive
into the right location, so take a moment to make sure you've selected
the correct key before you click Yes.
Importing a registry
hive file replaces the entire content of the selected key with the
contents of the file—regardless of its original source. That is, it
wipes out everything in the selected key and then adds the keys and
values from the file. When you import, be absolutely certain that you've
selected the correct key.
If you saved your backup
as a .reg file, you use the same process to import it. (As an
alternative, you can double-click the .reg file in Windows Explorer
without opening Registry Editor.) Unlike the registry hive file, however, the complete path to each key and value is stored as part of the file and it always restores to the same location. This approach for recovering from
registry editing mishaps is fine if you did not add new values or
subkeys to the section of the registry you're working with; it returns
existing data to its former state but doesn't alter the data you've
You mistakenly deleted data from the HKLM\System\CurrentControlSet hive
As those dire
warnings pointed out, improper changes to the registry can prevent your
computer from operating properly or even booting. This is particularly
true for changes to the HKLM\System\CurrentControlSet
hive. Because keys in that hive are so essential, Windows maintains a
backup, which you can restore when necessary. To do that, begin by
shutting down your computer. Start your computer and, during the boot
process, press F8. Use the arrow keys to select Last Known Good
Configuration and then press Enter.
5.2. Using System Protection to Save the Registry's State
Protection utility takes snapshots of your system's state, at prescribed
time intervals or on demand, and allows you to roll your system back to
an earlier state (called a restore point)
if you experience problems. Most of the registry is included in the
restore point. Creating a restore point before you begin working in the
registry is an excellent way to protect yourself against mishaps.6. Browsing and Editing with Registry Editor
Because of the registry's size, looking for a particular key, value, or data item can be daunting. In Registry Editor, the Find
command (on the Edit menu; also available by pressing Ctrl+F) works in
the forward direction only and does not wrap around when it gets to the
end of the registry. If you're not sure where the item you need is
located, select the highest level in the left pane before issuing the
command. If you have an approximate idea where the item you want is
located, you can save time by starting at a node closer to (but still
above) the target.
After you have located an item of interest, you can put it on the Favorites
list to simplify a return visit. Open the Favorites menu, click Add To
Favorites, and supply a friendly name (or accept the default). If you're
about to close Registry
Editor and know you'll be returning to the same key the next time you
open the editor, you can skip the Favorites step, because Registry
Editor always remembers your last position and returns to that position
in the next session.
Registry Editor includes a number of time-saving keyboard
shortcuts for navigating the registry. To move to the next subkey that
starts with a particular letter, simply type that letter when the focus
is in the left pane; in the right pane, use the same trick to jump to
the next value that begins with that letter. To open a key (revealing
its subkeys), press Right Arrow. To move up one level in the subkey hierarchy, press Left Arrow; a second press collapses the subkeys
of the current key. To move to the top of the hierarchy, press Home. To
quickly move between the left and right panes, use the Tab key. In the
right pane, press F2 to rename a value, and press Enter to open that
value and edit its data.
Once you get the hang of using these keyboard shortcuts, you'll find
it's usually easier to zip through the \subkey hierarchy with a
combination of arrow keys and letter keys than it is to open outline controls with the mouse.
6.1. Changing Data
You can change the data
associated with a value by selecting a value in the right pane and
pressing Enter or by double-clicking the value. Registry Editor pops up
an edit window appropriate for the value's data type.
6.2. Adding or Deleting Keys
To add a key, select
the new key's parent in the left pane, open the Edit menu, point to New,
and click Key. The new key arrives as a generically named outline
entry, exactly the way a new folder does in Windows Explorer. Type a new
name. To delete a key, select it and then press Delete.
6.3. Adding or Deleting Values
To add a value, select
the parent key; open the Edit menu, and point to New. On the submenu
that appears, click the type of value you want to add. A value of the
type you select appears in the right pane with a generic name. Type over
the generic name, press Enter twice, enter your data, and press Enter
once more. To delete a value, select it and press Delete.