Reconstructing a Corrupted Registry

Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Brien M. Posey, MCSE for TechRepublic.com

flaglogo

September 1999

A wise administrator once said, "The more you know about the Microsoft® Windows® registry, the more dangerous you are." In a way, this is true because when you know nothing about the registry—except for the horror stories you've heard about its destructive power—you're much more careful when making changes than you'd probably be if you knew the entire registry structure inside and out. What this means is that regardless of your skill level, you can inadvertently make a change to the registry that will destroy Windows. Fortunately, there are often steps you can take to correct the action. In this article, I'll show you some techniques you can use to repair a damaged registry.

Using Safe Mode

The easiest way to fix a damaged registry is to boot Windows into Safe Mode and run REGEDIT to make the corrections. Many times this technique will work even when registry problems prevent Windows from booting in Normal Mode, because Safe Mode uses a minimal set of drivers and registry instructions. Of course, for this technique to truly work, you must know where you made the initial mistake in the registry and what needs to be changed to make the correction.

Using the Import Feature

As you may know, the Registry Editor has the ability to import and export the registry to and from a text file. You can do this by using the Import Registry File and Export Registry File commands on the Registry Editor's Registry menu. If you plan on making modifications to your registry, you can export the registry to a text file. If something were to go wrong, you could later import your original registry back in.

Restoring from Backup

The Microsoft Backup tool has the ability to back up and restore the registry. In Windows 95, using the full system backup option automatically backs up the registry. Restoring a single file from such a backup set will restore the registry.

The Windows 98 Backup tool handles the registry differently. When preparing the backup, you can select the Options command from the Job menu. When you see the Backup Job Options dialog box, click the Advanced tab and select the Backup Windows Registry check box. Likewise, you can restore only the registry through a similar process.

The downside to using the backup program to restore the registry is that the registry will be restored to the exact state it was in at the time of the last backup. Therefore, if it's been a while since your last backup and you restore the registry, you'll lose any information relating to programs you've installed since the backup as well as changes you've made to the operating system.

Registry Repair Tools

If you suspect that your registry problems are fairly simple, there are a couple of tools you can run that automatically repair registry errors.

If you're using Windows 98, you can use the Registry Checker program to revert to an older version of the registry. In some situations, Windows 98 is smart enough to detect a severely corrupted registry and revert to an older registry automatically.

If you're not using Windows 98, the latest version of the Norton Utilities by Symantec offers a tool capable of repairing all but the most difficult registry problems.

When Windows Won't Boot

If Windows won't boot at all, you have two options. You could delete your existing copy of Windows and either install a fresh copy or restore a backup. Or you could attempt one last thing to restore the registry to a functional state.

The latter technique involves exporting the registry to a text file, making the necessary changes, and importing the changes back into Windows. What makes this technique so special is that it works in MS-DOS® mode. As you can see in Table A, the REGEDIT command contains several MS-DOS mode switches.

REGEDIT [/L:system] [/R:user] filename1
REGEDIT [/L:system] [/R:user] /C filename2
REGEDIT [/L:system] [/R:user] /E filename3 [regpath1]
REGEDIT [/L:system] [/R:user] /D regpath2

Table A

REGEDIT Command Switches

Purpose

/L:system

Location of System.dat

/R:USER

Location of User.dat

filename1

File to import into the registry

/C filename2

File to create registry from

/E filename3

File to export registry to

regpath1

Starting registry key to export from (defaults to exporting the entire registry)

/D regpath2

Specifies registry key to delete

The REGEDIT command switches.

To create the text file, you must export the registry. Assuming that your registry files are stored in the usual locations, you could do so with the following command:

REGEIT /E REGTEXT.TXT

Issuing this command will produce a text file similar to the one shown in Figure A. But remember, although I'm showing the text file in a Windows-based editor, you'll have only MS-DOS to work with. Therefore, you must have an MS-DOS-based text editor with an unlimited file size capability. The MS-DOS Editor won't work, since the registry export file can be very large. The file I created in our example was 3.5 MB. If you don't have a suitable text editor, you can use another computer to download one from the Internet.

Cc751047.recreg_a(en-us,TechNet.10).gif

Figure A: You can extract your registry to a text file.

Once you've made the necessary changes to the text file, you must import it. If you want to import the entire registry, you must use this command:

REGEDIT REGTEXT.TXT

Conclusion

In this article, I've discussed several techniques that you can use to recover a corrupted registry. However, you use these techniques at your own risk. As with any other registry modification, these techniques have the potential to make your problem worse than it already is.

Brien M. Posey is an MCSE and a freelance technical writer. He works as the Director of Information Systems for a large healthcare company. Brien has also worked as a network engineer for the Department of Defense. You can contact him at Brien_Posey@xpressions.com . (Because of the large volume of e-mail he receives, it's impossible for him to respond to every message. However, he does read them all.)

The above article is courtesy of TechRepublic https://www.techrepublic.com/ .

We at Microsoft Corporation hope that the information in this work is valuable to you. Your use of the information contained in this work, however, is at your sole risk. All information in this work is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Microsoft Corporation. Microsoft Corporation shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages. All prices for products mentioned in this document are subject to change without notice.

International rights.