• 2,940 views Mar 20, 2006

    This is part of my series on How to Install Windows Applications Silently.

    The registry is used in Windows to store configuration information. The registry contains ‘Hives’ which are like database files that each focus on a different catagory of settings, and each hive contains keys, which may have subkeys, which have values associated with them.Their are many occassions when you may want to ‘pre-populate’ a registry key, change an existing key, or even remove an existing key for an application you are installing. An example would be a program that stores it’s licensing information in the registry. Instead of having to manually type in the serial number each time you install a program, do this once, and then find where that registry key is stored, and copy it. You can then pre-populate this key when you install the program, saving yourself the hastle of tracking down the information and entering it by hand.

    The most common interface for dealing with the registry is through a program called “Registry Editor”, which is a part of Windows. Before we go any further, I need to tell you what Microsoft always makes clear when dealing with the registry:

    “If you use Registry Editor incorrectly, you can cause serious problems that may require you to reinstall your operating system. Microsoft does not guarantee that problems that you cause by using Registry Editor incorrectly can be resolved. Use Registry Editor at your own risk.”

    So, be careful! Simply exporting settings won’t hurt anything, but if you change or delete the wrong settings you can do harm. All of the settings I’ll suggest you change SHOULD be safe, I’ve done them myself on machines I work with, but all systems can be a bit different, and I cannot guarantee that they will work on yours, so first PLEASE test these settings on a non-production machine, in case something doesn’t work correctly. With all of that said, one way to start the Registry Editor is to open the ‘Start’ menu, choose ‘Run…’, type “Regedit” (without the quotes), and click ‘OK’. The Registry Editor will open on your screen, and will show you an expanding tree of folders representing the different hives in the registry. Here’s a brief description of the five hives:1

    HKEY_CURRENT_USER
    Contains the root of the configuration information for the user who is currently logged on. The user’s folders, screen colors, and Control Panel settings are stored here. This information is associated with the user’s profile. This key is sometimes abbreviated as “HKCU.”

    HKEY_USERS
    Contains all the actively loaded user profiles on the computer. HKEY_CURRENT_USER is a subkey of HKEY_USERS. HKEY_USERS is sometimes abbreviated as “HKU.”

    HKEY_LOCAL_MACHINE
    Contains configuration information particular to the computer (for any user). This key is sometimes abbreviated as “HKLM.”

    HKEY_CLASSES_ROOT
    Is a subkey of HKEY_LOCAL_MACHINE\Software. The information stored here makes sure that the correct program opens when you open a file by using Windows Explorer. This key is sometimes abbreviated as “HKCR.”

    HKEY_CURRENT_CONFIG
    Contains information about the hardware profile that is used by the local computer at system startup.

    The hardest part to exporting a registry key is finding it. When I refer to registry keys in these writeups, I may say something like:

    “Export the registry key [HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\MyProgram\License] to a file called HKLM.reg.”

    To do this, open the Registry Editor, expand HKEY_LOCAL_MACHINE (either click the plus symbol to the left of it, or double-click the name), then expand SOFTWARE, then expand MyCompany, then expand MyProgram, and finally click once on License. You’ve now selected the License registry key. To Export it, go to the File menu and choose Export…, enter the file name (HKLM in this case), choose a location (typically the application folder you created for this distribution), and click Save. That’s it!

    The Registry Editor will create a text file named HKLM.reg in the location you chose. This file is a simple text file that will look like:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany]
    @=”"

    [HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\MyProgram]
    @=”"
    “Setting1″=dword:00000001

    You can edit the file by right-clicking on it, and choosing edit, or you can open it in any text editing program. This file MUST NOT contain any formatting, it is a simple text file. If you ever have problems with your file not importing correctly, open the file with Notepad and save it as an ANSI file (in the Save As window, choose ANSI as the file type at the bottom). This should clear any objectionable formatting from the file. In the past I’ve experienced problems with the ModifyProfiles.exe application (used in some of the installs I’ll detail) occassionally not importing my files properly, and saving them as ANSI solved that problem.


    1. support.microsoft.com/kb/256986/EN-US/ [back]
  • Leave a Comment

    Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.