A great feature of the Registry Editor is it's ability to import and export
registry settings to a text file, this text file, identified by the .REG
extension, can then be saved or shared with other people to easily modify local
registry settings.
You can see the layout of these text files by simply
exporting a key to a file and opening it in Notepad, to do this using the
Registry Editor select a key, then from the "Registry" menu choose "Export
Registry File...", choose a filename and save.
If you open this file in notepad
you will see a file similar to the example below:
The layout is quite simple, REGEDIT4 indicated the file type and version, [HKEY_LOCAL_MACHINE\SYSTEM\Setup]
indicated the key the values are from,
"SetupType"=dword:00000000 are the values
themselves the portion after the "=" will vary depending on the type of value
they are; DWORD, String or Binary.
So by simply editing this file to make the changes you want, it can then be
easily distributed and all that need to be done is to double-click, or choose
"Import" from the Registry menu, for the settings to be added to the system
Registry.
Deleting keys or values using a REG file
It is also possible to delete keys and values using REG files.
To delete a key
start by using the same format as the the REG file above, but place a "-" symbol
in front of the key name you want to delete. For example to delete the [HKEY_LOCAL_MACHINE\SYSTEM\Setup]
key the reg file would look like this:
REGEDIT4
[-HKEY_LOCAL_MACHINE\SYSTEM\Setup]
The format used to delete individual values is similar, but instead of a minus
sign in front of the whole key, place it after the equal sign of the value. For
example, to delete the value "SetupType" the file would look like:
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\Setup]
"SetupType"=-
Use this feature with care, as deleting the wrong key or value could cause major
problems within the registry, so remember to always make a backup first.
Regedit Command Line Options
Regedit has a number of command line options to help automate it's use in either
batch files or from the command prompt. Listed below are some of the options,
please note the some of the functions are operating system specific.
regedit.exe [options] [filename] [regpath]
[filename] Import .reg file into the registry
/s [filename] Silent import, i.e. hide confirmation box when importing files
/e [filename] [regpath] Export the registry to [filename] starting at [regpath]
e.g. regedit /e file.reg HKEY_USERS\.DEFAULT
/L:system Specify the location of the system.dat to use
/R:user Specify the location of the user.dat to use
/C [filename] Compress (Windows 98)
/D [regpath] Delete the specified key (Windows 98)
Maintaining the Registry
How can you backup and restore the Registry?
Windows 95
Microsoft included a utility on the Windows 95 CD-ROM that lets you create
backups of the Registry on your computer. The Microsoft Configuration Backup
program, CFGBACK.EXE, can be found in the \Other\Misc\Cfgback directory on the
Windows 95 CD-ROM.
This utility lets you create up to nine different backup
copies of the Registry, which it stores, with the extension RBK, in your
\Windows directory. If your system is set up for multiple users, CFGBACK.EXE
won't back up the USER.DAT file.
After you have backed up your Registry, you can copy the RBK file onto a floppy
disk for safekeeping. However, to restore from a backup, the RBK file must
reside in the \Windows directory.
Windows 95 stores the backups in compressed
form, which you can then restore only by using the CFGBACK.EXE utility.
Windows 98
Microsoft Windows 98 automatically creates a backup copy of the registry every
time Windows starts, in addition to this you can manually create a backup using
the Registry Checker utility by running SCANREGW.EXE from Start | Run menu.
What to do if you get a Corrupted Registry
Windows 95, 98 and NT all have a simple registry backup mechanism that is quite
reliable, although you should never simply rely on it, remember to always make a
backup first!
Windows 95
In the Windows directory there are several hidden files, four of these will be
SYSTEM.DAT & USER.DAT, your current registry, and SYSTEM.DA0 & USER.DA0, a
backup of your registry.
Windows 9x has a nice reature in that every time it
appears to start successfully it will copy the registry over these backup files,
so just in case something goes wrong can can restore it to a known good state.
To restore the registry follow these instruction:
1. Click the Start button, and then click Shut Down.
2. Click Restart The Computer In MS-DOS Mode, then click Yes.
3. Change to your Windows directory. For example, if your Windows directory is
c:\windows, you would type the following:
cd c:\windows
4. Type the following commands, pressing ENTER after each one. (Note that
SYSTEM.DA0 and USER.DA0 contain the number zero.)
Following this procedure will restore your registry to its state when you last
successfully started your computer.
If all else fails, there is a file on your hard disk named SYSTEM.1ST that was
created when Windows 95 was first successfully installed. If necessary you could
also change the file attributes of this file from read-only and hidden to
archive to copy the file to C:\WINDOWS\SYSTEM.DAT.
Windows NT
On Windows NT you can use either the "Last Known Good" option or RDISK to
restore to registry to a stable working configuration.
How can I clean out old data from the Registry?
Although it's possible to manually go through the Registry and delete unwanted
entries, Microsoft provides a tool to automate the process, the program is
called RegClean.
RegClean analyzes Windows Registry keys stored in a common
location in the Windows Registry. It finds keys that contain erroneous values,
it removes them from the Windows Registry after having recording those entries
in the Undo.Reg file.