Windows Vista: The Complete Reference (Complete Reference Series)

The Windows Registry contains a great deal of information beyond the file associations discussed in the previous section. For the most part, you won't need to do any editing yourself, but occasionally, a bug fix or parameter change requires a change to the Registry, so you need to be prepared to do a little editing now and then. If you're interested in how Windows works, you can also spend as much time as you want nosing around the Registry with the Registry Editor program.

Caution  

Never make changes to the Registry without first making a backup! Better yet, include the Registry in your daily backups (see Chapter 10).

Restoring the Registry

If the Registry is damaged, you can restore it from a backup. Follow these steps:

  1. Save your files and close all your programs.

  2. Choose Start Shut Off. Windows shuts down.

  3. Restart the computer.

  4. When you see the message Please Select The Operating System To Start, press FS. Windows displays a list of options (see Chapter 37).

  5. Press the UP-ARROW or DOWN-ARROW until you highlight the Last Known Good Configuration option, and press ENTER. (If the ARROW keys don't work, press NUM LOCK to enable them.)

  6. Choose the operating system (such as Windows Vista Ultimate). Windows then restores your most recently backed -up values for the HKEY_LOCAL_MACHINE\ System\CurrentControlSet hive in the Registry and restarts Windows.

If the Registry entries for an application get damaged, consider uninstalling and reinstalling the program. If restoring a backup of the Registry still doesn't fix your problem, you may have to back up your data, reformat the disk (or partition) on which Windows is installed, and reinstall Windows and all your programs.

Note  

System Restore can also restore a previous version of the Registry (see "Returning Your System to a Predefined State with System Restore" in Chapter 37).

Running Registry Editor

Registry Editor (Regedit for short) lets you edit anything in the Registry. To run Registry Editor, select Start All Programs Accessories Run, type regedit , and press ENTER. This chapter describes Registry Editor version 6.

Caution  

Registry Editor has almost no built-in checks or validation, so be very sure that you make any changes correctly. It does not have, for instance, an Undo command. Incorrect Registry entries can lead to anything from occasional flaky behavior to complete system failure. We suggest that you export the keys that you plan to edit before making any changes, so that you can reimport them if the changes cause problems.

Finding Registry Entries

Registry Editor has a two-part window, shown in Figure 40-1, much like Windows Explorer. Each key is shown as a folder in the left pane of the Registry Editor window. When you select a key in the left pane, the name and data of each of its values appear in the right pane. You can expand and contract parts of the name tree by clicking the + and ˆ’ icons in the key area. Select any key to see the names and data of the values, if any, associated with that key.

Figure 40-1: Looking at the Registry.

If you know the name of the key you want, you can navigate through the key names similar to the way you navigate through files in Windows Explorer.

If you don't know the name of the key, you can search for it by choosing Edit Find (or pressing CTRL-F). You can search for any combination of keys, value names, and value data. For example, if you mistyped your name at the time you set up Windows and want to correct it, search for the mistyped name as value data. Press F3 to step from one match to the next .

Tip  

As you edit Registry entries, Registry Editor makes the changes right away-there's no Save, Cancel, or Undo command. You can edit the Registry and leave the Registry Editor window open while you check whether your changes produce the desired effect. Some programs aren't affected by Registry changes until they are restarted; others reflect the changes immediately.

When you run Registry Editor again, it displays the key that you were looking at when you last exited the program, so it's easy to continue making changes to the same key.

Adding and Changing Registry Entries

You can add, edit, and delete Registry entries (but be sure you back them up first):

You can't change the type of a value, so you have to enter a text string, a numeric value, or a string of hexadecimal digits, depending on the type of the data.

Tip  

If you're not absolutely sure about deleting a key, rename it. Add an underscore or number to the end, so that the Registry doesn't recognize it but you will if you need to change it back later.

You can also rename and delete keys and values by using the Edit menu.

Tip  

If you want to remember the name of a Registry key-or tell a friend about it-you can copy it to the Clipboard. Select the key whose complete name you want, and choose Edit Copy Key Name.

Editing the Registry as a Text File

Another way to edit the Registry is to export all or part of the Registry to a text file, edit the text file, and then import the changed values back into the Registry. You can export and import the entire Registry or one "Ibranch" of the Registry's tree of keys. Registry Editor stores the exported Registry entries in a registration file with the extension .reg.

A registration file consists of a series of lines that look like this:

[HKEY_CLASSES_ROOT\.bfc\ShellNew\Config] "NoExtension"="Temp

The first line is the name of the key ( enclosed in square brackets) and the lines that follow are the values in the key, in the format "name" = "value" .

Note  

Windows Vista (like Windows XP) exports the Registry using Unicode rather than plain text. You can't export keys from the Windows Vista Registry and import them into a Windows Me/9x Registry.

Follow these steps to edit the Registry by using a text editor:

  1. Select a hive or key in the left pane, choosing one that contains all the keys that you want to edit. To export the entire Registry, select the Computer item at the root of the Registry tree.

  2. Choose File Export to write the text file. Registry Editor asks you for the folder and filename to use for the registration file. Then it writes the data into the new file, which may take a few minutes.

  3. Edit the registration file in any text editor. (Notepad works fine.) Right-click the REG file in Windows Explorer and choose Edit from the shortcut menu that appears. Notepad runs (or another text editor, if you choose it). Make as few changes as possible to the file and save the file.

  4. In Registry Editor, choose File Import to read the edited file back into the Registry. The keys and values in the imported file replace the corresponding keys and values in the Registry. Note that if you delete a key or value in the text file, importing the file doesn't delete the key or value in the Registry.

Tip  

The Registry is quite large-an exported version of the whole thing can be 50MB or more. If you do plan to edit it, just export the branch you plan to work on.

Running Programs on Startup

You can tell Windows to start a program automatically when Windows starts up by including a shortcut to it in the Startup folder of your Start menu (see "Starting Programs when Windows Starts" in Chapter 2). However, there are two other ways to run a program automatically when Windows starts: lines in the Win.ini file and keys in the Registry.

The Win.ini file (which is stored in C:\Windows, assuming that Windows in installed on C:), can include lines like this:

run= program load= program

Replace program with the pathname of the file that contains the program. To stop a program from running, remove this line from the Win.ini file, or add a semicolon at the beginning of the line.

Two places in the Registry can contain entries that run programs at Windows startup. Look in these two keys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Current Version HKEY_CURRENT_USER\Software\Microsoft\Windows\Current Version

These keys can contain keys named Run, RunOnce, or RunOnceEx, which contain values that start programs when Windows starts. To stop the program from running, remove or rename the key.

 

Категории