There's no question among Windows experts that the registry is incredibly important. Administrators find they need more knowledge than just an understanding of the registry's functions; to get the best performance, an administrator has to be able to maintain the registry well. Specifically, the registry must be kept clean and free of spurious entries, it needs to be compacted periodically if users or applications are being added and...
removed from the system often, and it needs to be backed up, in the event of disaster.
Keeping it clean
Every entry in the registry -- every key and every value -- takes up space. While most systems these days have no shortage of space, it's still good practice to make sure that the registry does not take up more space than it needs to. A smaller registry means shorter boot times. Additionally, less memory is taken up when a smaller registry is loaded into RAM, and fewer things will go wrong overall.
In theory, every application worth its salt comes with an uninstaller that removes all traces of the app from one's system. But the simple truth is that uninstallers almost never completely remove the remnants of the application they're supposed to uninstall, especially when it comes to registry entries. Part of this may be due to a badly written uninstaller, but what often happens is that other applications can complicate the process. If a second application is installed after the installation of the one you want to uninstall, and if the two applications share components, you may encounter problems.
Another less common but immensely frustrating problem in the same vein comes up when you try to install a newer version of an application that was uninstalled previously. Sometime the uninstall doesn't completely remove all prior registry entries, and if the newer version of the program has significant changes, especially if it's a completely new revision to the left of the decimal point, then the new install may conflict with the remnants of the old. The installation may not take, or the reinstalled application may not work correctly.
How do you deal with this problem? Rather than root out and erase spurious entries by hand, which almost never works (and is time-consuming to boot), a third-party utility that does the job for you is a good place to start. One such app is RegCleaner, which intelligently finds orphaned file and .DLL references. It also backs up deleted entries to a file, in the event that something critical is deleted. Another good program, Registry Healer, also does search-and-destroy on dead registry entries, and it can also compact the registry. Read on for more on this.
Down to size
The registry is basically a series of files. Like any files that are written and rewritten many times, it can get fragmented, both internally and externally. Internal fragmentation takes place when keys or values are deleted, creating gaps in the registry's internal data structure. This slows down access to different parts of the registry because more of it has to be scanned. External fragmentation is when the physical registry files themselves become fragmented, which can slow down registry operations even further.
Because the registry is a locked system file, it can't be defragmented with the conventional defrag tool in Windows 2000. To defragment the registry physically, you'll need a third-party utility. PageDefrag is one such tool. For internal defragmentation, you can use the above-mentioned Registry Healer; compacting the registry is akin to an internal defrag.
That said, there are a few things you can do to cut down on registry fragmentation. One, don't create unneeded user accounts. Each user account adds another subsection to the registry, which can be quite large if you have many installed applications. (Microsoft also discourages deleting user accounts on Windows 2000 servers for forensic reasons; if you delete a user account, all of the security information with that account vanishes, and it becomes more difficult to determine if someone attempted to use that account illicitly in the future. It stands to reason you should create as few of them as possible.) Two, don't install software arbitrarily. This should be self-evident, since cleaning up after it can be a headache.
Protection and backups
The physical location of the registry in a Windows 2000 system is in the <%SystemRoot%>\system32\config folder. If the registry gets damaged, whether because of sabotage, power outage, viruses or what have you, there are ways to get around it. A backup copy of the registry is also kept during each boot cycle and is loaded when someone attempts a Last Known Good boot. This way, at least one working copy of the registry should be on hand in the event something catastrophic happens to the present one. Attempting a Last Known Good boot is one of the quickest ways to get around registry corruption -- simply press F8 at boot time and select Last Known Good from the boot menu.
Still, it doesn't hurt to make regular offline backups of the registry. Backing up the <%SystemRoot%>\system32\config "by hand" -- that is, just copying the files in there -- will not back up the registry, because these files are considered locked by the system and cannot be copied when Windows is running. Theoretically, it's possible to copy them by booting to a parallel installation of Windows and copying the files by hand, but this is more complicated than it needs to be.
The easiest way to back up the registry files is to use the Windows backup utility (NTBACKUP) to perform a system state backup, which contains a full copy of the registry. Running the Automated System Recovery Wizard from NTBACKUP will also do this.
What if you have a catastrophic failure and cannot even boot Windows from the Last Known Good configuration? In a case like this, use the Windows 2000 Recovery Console to replace the registry files:
- Extract the backed-up registry files on another machine and burn them to a CD.
- Boot the Recovery Console.
- Insert the CD with the backed-up files, System and Software.
- Copy the backups into the system32\config directory. Answer "yes" to any prompts to overwrite system files.
- Reboot normally.
Serdar Yegulalp is the editor of the Windows 2000 Power Users Newsletter.