[ Home ][ About ][ Experience ][ Contact ]

Backing Up Software Registry Settings

One of the more annoying aspects of backing up and restoring Windows 9x/NT/2000 applications involves the registry. Of course, backing it up isn't so bad. You simply select the option (in pretty much every backup software package) to backup the registry. It's restoring the settings that can cause headaches. Many backup programs force you to restore the entire registry, which can cause problems with other applications or with Windows itself - especially if you have changed some driver settings since your last backup. If you just reinstalled a piece of software, or want to copy your configuration to another computer (or user registry hive in NT), this is unacceptable.

For the past several months, I've been using a technique that requires a little bit of extra time to set up, but once in place makes backing up and restoring software registry settings for individual applications downright simple. It revolves around the very poorly documented command line parameters for the REGEDIT program that's included with Windows 9x and NT 4.0 (the REGEDIT program that comes with NT 3.x is different; it's for managing OLE object registration). Please note that improperly modifying the Windows registry may severely damage your system. The technique described below is intended only for professional technicians who fully understand the various techniques for and implications of manually modifying the Windows registry. If you are the least bit unsure of what you are doing, please obtain professional assistance.

The first thing that you do is identify the registry keys associated with each application that you're interested in saving the configuration for. Generally, these are located in HKEY_CURRENT_USER\Software\CompanyName\Application and HKEY_LOCAL_MACHINE\Software\CompanyName\Application, where CompanyName and Application refer the publisher and the name of the application, respectively. To use this technique, you generally need only know the parent key for the application; any child keys are automatically included with the parent. The only exception involves situations where you only want to backup / restore certain child keys for an application; to date I've never actually run into this. If this situation occurs, simply treat each child key as a separate parent key.

Once you have a list of keys that you want to back up, create a batch file called BACKUPREG.CMD (or you can call it whatever you want) that you execute prior to using your backup software. This batch file calls the REGEDIT program several times, once for each parent key that you want to back up. The format for doing so is as follows:

        regedit /e OUTPUT.REG KEY_TO_BACKUP

The /e parameter tells REGEDIT to export the specified key. You can specify any filename that you want instead of OUTPUT.REG. The only quirk here is that REGEDIT requires that you use a DOS-compatible filename (no long file or directory names are permitted, all must be in 8.3 format). If you want to use a path that contains long filenames, you must use the DOS-friendly (8.3 format) version of that path. The easiest way to do determine this path is to start a command prompt, change to the directory in question, and run a 16-bit DOS application (I use EDIT.EXE). After exiting the 16-bit DOS application, the path shown in your command prompt will be in a DOS-friendly format. Here is an example of a path that contains long filenames and it's DOS-friendly equivalent:

Long Filename Path:    E:\Program Files\Borland\CBuilder4\Bin\bcb4.reg

DOS-Friendly Path:    E:\Progra~1\Borland\CBuilder4\Bin\bcb4.reg

The KEY_TO_BACKUP parameter specifies the parent key that you want to back up. If this key contains spaces, than it must be enclosed in quotation marks.  

Here are two complete examples of the use of the REGEDIT command for backing up registry keys from the command line, taken from my own BACKUPREG.CMD file:

regedit /e D:\WINNT\Profiles\ECarls~1\ShortBar.reg "HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\OFFICE\9.0\SHORTCUT BAR"

regedit /e E:\Progra~1\Borland\CBuilder4\Bin\bcb4.reg HKEY_CURRENT_USER\SOFTWARE\BORLAND\C++Builder\4.0

Once you have created the appropriate output files, be sure to make sure that they are included in your backup set. Here are some final thoughts to keep in mind when using this technique:

  1. I strongly recommend using the .REG extension for your REGEDIT output files, as it is by default associated with the REGEDIT program. This means that simply double-clicking a .REG file within Windows Explorer will automatically use REGEDIT to load the settings contained in that file into your Windows registry.

  2. When restoring registry settings you will overwrite any existing settings in your Windows registry.

  3. The REGEDIT program gives no visual indication of success or failure when you run it from the command line. It's very important to open the files it creates and verify that the contents are indeed what you wanted. Again, when run from the command line the REGEDIT program returns no messages indicating the success or failure of an operation.

  4. If the output file that you specify for REGEDIT already exists, it will be completely overwritten.

  5. It's usually convenient to launch your backup utility at the end of your BACKUPREG.CMD file.

  6. It's still important to do a full registry backup with your backup utility.

  7. Programs don't always store all of their registry information in the obvious places. Be sure to check thoroughly.

  8. Finally, as mentioned above, be very sure about what you are doing before messing with the Windows registry. Otherwise, Very Bad Things involving malfunctioning computers and data loss may occur.

 

Previous Article - Strong Passwords Simplified

Next Article - Switching Between SMP and Uniprocessor NT HALs

Articles (C) 1999-2000 Praecelsus Consulting, Inc. All Rights Reserved, however, permission is granted to copy and distribute this article verbatim for non-commercial purposes as long as the author (Erik Carlseen / Praecelsus Consulting, Inc.) and source (www.praecelsus.com) are attributed and specified.

[ Home ][ About ][ Experience ][ Contact ]

(C) 1999-2000 Praecelsus Consulting, Inc. All Rights Reserved.