Safekeeping the Windows XP Registry
Published: March 17, 2003
By Jerry Honeycutt, Windows XP Expert Zone Community Columnist
Editor's Note: Past articles by members of the online community are archived for your use. The information may become outdated as technology changes. For the most current information, please search the Web site or post a question in the newsgroups.

Your Windows XP settings are stored in the operating system's registry. So if you want to safeguard your settings, you must learn how to protect the registry's contents. For that matter, if you want to tweak the operating system using the registry, make doubly sure that you've left a way to get out of any trouble you might cause through overly-enthusiastic hacking.
Enthusiasts refer to the practice of customizing Windows XP using the registry as "hacking the registry." Don't worry, it's legal. The slang term has persisted even though "hacking" today usually refers to illegal activity.
This article is largely excerpted from my book, Microsoft Windows XP Registry Guide (Microsoft Press, 2002). I've condensed a 12,000 word chapter into this column, so we're only scratching the surface here. If you want to learn more about safekeeping the Windows XP registry, take a look at Chapter 3, "Backing up the Registry."
For an introduction to working with the Windows XP registry, see my column, Customizing Your PC with the Windows XP Registry, and the Knowledge Base article, Description of the Microsoft Windows Registry.
This column is geared to advanced users of Windows XP. Although even advanced users should be aware that if you use Registry Editor incorrectly, you can cause serious problems that may require you to reinstall your operating system. Microsoft recommends that before you edit the registry, you back up the registry and understand how to restore it if a problem occurs.
In this column, I'll explain how to back up the registry and restore it if things go awry. You'll learn how to use System Restore, which ensures that you can roll back the configuration of Windows XP to an earlier snapshot that the operating system makes automatically. Also, I like to save keys to hive files before making big changes to the registry so that I can restore those hive files if I make a mess of things. Both of these tools require preparation in advance. In other words, after something goes wrong is not the best time for backing up the registry—back up the registry first.
Practice Safe Hacking
Here, you'll learn a few methods for protecting the registry while you're editing it. This is for all you Windows XP enthusiasts who edit the registry using the Registry Editor (Regedit). If you use any one of these methods, you'll almost never make a change that you can't restore. Keep in mind that I use these methods to back up specific branches of the registry while working in those branches. I don't use them to back up the entire registry. System Restore takes care of that for you, so you don't have to manually back up the whole thing.
The first method is making backup copies of individual values, which you can quickly restore in the registry. These backups also document the changes you make. Here's how to do it:
1. | Rename the original value to something like Initials_ Name, where Initials is your initials, and Name is the value's original name. |
2. | Add a date if you think you're going to change the value often. |
3. | Add a new value using the original name and type but with new data. You're all set to change the value and if you don't like the result, you can restore the original value with little effort. |
Figure 1 shows backup settings in the key HKCU\Control Panel\Desktop. The backup values begin with JH_. Likewise, instead of deleting a value, which you can only recover by memory because the Registry Editor doesn't have an Undo feature, rename the value to hide it from any program that's looking for it. The effect is the same, and you can always restore the value by restoring its name.

Figure 1
The second method is to export the part of the registry in which you're working to a REG file. Import the REG file to restore the original settings. I'm not as keen on this method as the next method I describe, since importing a REG file in to the registry doesn't always restore keys to their original states (importing a REG file doesn't remove settings from the registry that you've added since creating the REG file). This is an acceptable option for real quick backup copies of individual values, however, since you can edit REG files to remove values that you don't want to restore.
The third method (and my first choice when making big changes) is to export branches to hive files. Hive files are better than REG files for backing up the registry. When you restore a hive file containing a key, the Registry Editor completely replaces the current key and all of its subkeys with the contents of the hive file. Exporting branches to hive files is similar to exporting them to REG files; you just pick a different file type:
1. | Click Start, click Run, type regedit, and click OK. |
2. | On the File menu, click Export. |
3. | In the Save as type list, click Registry Hive Files. |
4. | Type the name of the new hive file, and then click Save. |
Reverse the process to restore your settings: In the Registry Editor, click File, click Import, click Registry Hive Files in the Save as type list, type the name of the hive file to which you backed up your settings, and then click Open. You can use any file extension you like, but I prefer to give hive files the .dat extension. The .hiv extension is also common for hive files.
If these techniques fail or if you're planning on major registry surgery, move on to System Restore. System Restore can get you out of trouble most of the time; it only fails when Windows XP is so far gone that it no longer starts properly. In that case, you're left with Automated System Recovery and Recovery Console. See Reliability Improvements in Windows XP Professional for an overview of this console. But first, try starting Windows XP in safe mode and then run System Restore.
Use System Restore
System Restore returns your computer to a previous snapshot without losing recent personal information, such as documents, history lists, favorites, or e-mail. It monitors the computer and many applications for changes and creates restore points. I call these restore points snapshots, but they're really instructions for undoing recent changes. You restore these snapshots when your configuration isn't working.
By default, Windows XP creates restore points daily and when significant events occur, such as installing an application or device driver. System Restore is ideal for serious work in the registry because you can create your own restore points any time you like. You can also change the snapshot schedule or even script System Restore. Yes, I'm going to show you how.
System Restore requires at least 200 MB of available disk space. If 200 MB of space isn't available, Windows XP disables System Restore. By default, Windows XP allocates 12 percent of the hard disk's size (or 400 MB on hard disks that are smaller than 4 GB), and this happens to be the most that Windows XP can give it.
You can otherwise configure the amount of disk space System Restore consumes, though.
To change the disk space System Restore uses:
1. | Click Start, click Control Panel, click Performance and Maintenance, and then click System. |
2. | On the System Restore tab, drag the slider left or right to adjust the amount of disk space it uses. |
However, don't reduce the amount much because doing so limits the number of restore points that System Restore can maintain.
Here's how to create a restore point using System Restore:
1. | Click Start, point to All Programs, point to Accessories, point to System Tools, and then click System Restore. |
2. | Click Create a Restore Point, and then click Next. |
3. | In the Restore point description box, type a descriptive name for the restore point, and then click Create. System Restore adds the date and time to the name of the restore point. |
To restore a checkpoint, follow these steps:
1. | Start System Restore. |
2. | Click Restore my computer to an earlier time option, and then click Next. |
3. | Select the restore point that you want to restore, and then click Next. System Restore maintains up to 90 days of restore points, given enough disk space, so you can move backward and forward in the calendar to see the restore points created on each day. In the calendar, shown in Figure 2, bold dates are those that contain restore points. |
4. | Click a date, and then click the restore point in the list. |
5. | Click Next again and Windows XP restarts so it can restore your configuration to the restore point you selected.  Figure 2 Note: If your configuration is unstable enough, sometimes you won't be able to start Windows XP normally. That leaves you with safe mode, a method of starting Windows using basic files and drivers only, without networking. Safe mode is available by pressing the F8 key when prompted during startup. In safe mode, you can't create restore points, but you can restore ones that have already been created. So if Windows XP doesn't start normally, start it in safe mode, restore to an earlier configuration, and then restart the computer. See a Description of Safe Mode Boot Options in Windows XP and How to Perform Advanced Clean Boot Troubleshooting in Windows XP for more information about safe mode. |
You can script System Restore to make taking snapshots quicker and easier. Wouldn't you like to have a script sitting on your desktop that you can run before making changes to the registry? Here's how to create a script that will create a restore point when you double-click it:
1. | Using Notepad, type the following listing and save it with the file extension .vbs and make sure that you enclose the file name in quotation marks so Notepad doesn't add the .txt file extension to the name. Set SRP = GetObject( "winmgmts:\\.\root\default:Systemrestore" )
CSRP = SRP.CreateRestorePoint( "Hacked the registry", 0, 100 ) |
2. | Double-click the script file any time you want to make a snapshot, presumably before opening the Registry Editor to tweak the registry. |
Find More Backup Methods
If you follow through on any of the suggestions in this article or in my book, you'll never hack your registry to death. You'll never make a mistake so bad that you leave Windows XP in ruins. In other words, you'll always have a way out of trouble.
In Microsoft Windows XP Registry Guide (Microsoft Press, 2002), you'll find many more suggestions for backing up and restoring the registry. It also shows you how to repair common problems, such as fixing incorrect settings, repairing device settings, and how to manually uninstall applications. You can buy a copy at Shop Microsoft.com or at your favorite technical bookseller.
You can download the book's examples from the Microsoft WindowsXP Registry Guide MSN group that I use to support its readers. If you have any questions about my book, including whether or not it covers a particular topic, please send them to jerry@honeycutt.com.
Expert Zone Columnist Jerry Honeycutt is a writer, speaker, and technologist who has written over 25 books, including Microsoft Windows XP Registry Guide (Microsoft Press, 2002). He frequently writes about customizing and deploying Windows XP.