Working with Hive Files
There are two scenarios in which working with hive files is an important part of an IT professional's job. The first is when creating a default user profile, which you learn how to do in Chapter 12, “Deploying User Profiles.” The other is troubleshooting. You can take a hive file from a computer or user profile that's not working properly, repair it on another computer, and then replace it on the original computer.
Loading a hive file is different from importing a hive file. When you import a hive file, which you learned how to do in the previous section, you actually replace settings in the registry. In other words, you load the hive file over existing settings. When you load a hive file, you create a whole new branch in the registry that doesn't overlap or replace any other branch. This enables you to edit the settings in a hive file without changing your own settings. Here's how to load a hive file into the registry:
In the key pane, click either HKU or HKLM.
On the File menu, click Load Hive.
In the File Name box, type the path and file name of the hive file you're loading, and then click Open.
In the Key Name box, shown in Figure 2-6, type the name you want to assign to the hive.
The name you give to the key is arbitrary. Use any name that helps you identify the hive file that you're loading. All you're doing in this step is creating a root key in which to load the hive file.
Figure 2-6 Type a name that describes what the hive file contains.
When you're finished editing settings in the hive file, you must unload it before doing anything else with it, such as copying it to a removable disk. That's because Windows locks the file until you unload it. Unloading a hive file is easy: click the key into which you loaded the hive, which you specified in step 4, and then click Unload Hive on the File menu. If you get an error message when you try to copy the hive file or profile folder that contains a hive file, you probably forgot to unload it from the registry.
Command-Line Alternative
Windows comes with a great command-line alternative to Regedit. Anything you can do with Regedit, you can also do with Console Registry Tool for Windows, otherwise known as Reg.exe. And this tool is installed by default with Windows XP and Windows Server 2003, unlike earlier versions of Windows, which required you to get the tool from the resource kits.
What's so great about a command-line registry editor? You can use it to script registry changes. For example, you can write a batch file that automatically backs up a portion of the registry. Imagine a batch file that extracts hardware information from a computer and dumps it onto a network share. That's a quick inventory system. Recently, I used Reg.exe to extract the GUID from every computer on a network so that I could configure them as managed computers in Active Directory. (See Chapter 1, “Learning the Basics.”)This was a huge timesaver.
Chapter 11, “Scripting Registry Changes,” describes Console Registry Tool for Windows in great detail. For more information, you can also type Reg.exe at the Windows command prompt.