MOD2000: How to Add Registry Settings During Installation of a Custom Application

ID: Q240998


The information in this article applies to:
  • Microsoft Office 2000 Developer

Moderate: Requires basic macro, coding, and interoperability skills.

IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.

SUMMARY

When you use the "Package and Deployment" Wizard to create a package, there is no interface to specify registry settings to be created during the installation of your application. This behavior is different from the Setup Wizard included with Office 97 Developer Edition.

You can, however, add registry files (*.reg) to the package that you have either exported from the Windows Registry on your development computer or that you have created in Notepad. This article includes an example of how to do this.

NOTE: Because a registry file (*.reg) contains static information, you cannot add information that references user-defined folders to the registry of the target computer.


MORE INFORMATION

Registry files (*.reg) that are added to the file list in the "Package and Deployment" Wizard are automatically applied to the registry during installation of your package.

When you add any registry files to the file list, an extra screen called Package and Deployment Wizard - Registry Entries is displayed. This screen has a list of all the registry files that you are including, and it enables you to specify for each file whether it is to be copied and whether it is to be run during Setup. The default is for each registry file to be run but not to be copied.

To demonstrate how to create a simple package that includes a registry file, follow these steps. The example shows you how to package a registry file that causes the Windows Calculator to run once.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

  1. Start Notepad and type the following text:


  2. 
       REGEDIT4
    
       [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
       "RunCalculator"="Calc.exe" 
  3. On the File menu, click Save As.


  4. Browse to your Microsoft Office folder.


  5. In the Save As dialog box, click All Files in the Save as type list


  6. In the File name box, type Test.reg.


  7. Click Save, and then quit Notepad.

    This example uses the Test.reg file as the registry file to add to the package.


  8. In Access, open the sample database Northwind.mdb.


  9. Press ALT+F11 to switch to the Visual Basic Editor.


  10. On the Add-ins menu, if the Package and Deployment Wizard is listed, skip to step 13.


  11. On the Add-ins menu, click Add-in Manager.


  12. In the Available Add-ins list, click VBA Package and Deployment Wizard.


  13. Under Load Behavior, click Loaded/Unloaded, and then click OK.


  14. On the Add-ins menu, click Package and Deployment Wizard.


  15. In the Package and Deployment Wizard dialog box, click Package.


  16. Click Next and accept the defaults until you see the Package and Deployment Wizard - Included Files screen.


  17. Make sure that the Include Access Runtime check box is selected.


  18. Click Add and add the Test.reg file that you created in steps 1 through 6.


  19. Click Next to move to the Package and Deployment Wizard - Registry Information screen.


  20. On the line for Test.reg, make sure Copy File is set to No and Update Registry is set to Yes.


  21. Continue through the wizard until it is finished, and then close the wizard.


  22. Install the package onto a clean Windows computer (a computer that has a newly installed version of Windows, and no other applications).


  23. Restart the computer.


Note that Calculator starts automatically.

NOTE: As the name implies, the RunOnce key only exists for one startup of Windows. If you were to restart the computer in the example a second time, Calculator would not run, because Windows deletes the key after it has run once.

Using the Registry Editor

If you already have existing registry entries on your development computer that you want to include in your package, you can export them out to a registry file by using the Registry editor. To do this, follow these steps.

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys and Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).
  1. Click Start, and then click Run.


  2. Type regedit, and then click OK. The Registry Editor opens.


  3. Browse to the registry key that you want to export, and then click to select it.


  4. On the Registry menu, click Export Registry File.


  5. In the File name box, type a unique name for the key.


  6. Make note of which folder is displayed in the Save In box, and then click Save.


This exports the key. You can include the file in your package as shown in the previous section. If you need to, you can first open the exported registry file in a text editor, such as Notepad, to make any custom changes for your package.

IMPORTANT: If you open a registry file in Notepad and make changes, always use the Save as command, and make sure the File type box in the Save as dialog box is set to All Files. If you have the box set to Text Files, you create a file with a .txt extension, and the file is not recognized as a registry file.

Additional query words: Reg

Keywords : kbdta modPDWizard
Version : :
Platform :
Issue type : kbhowto


Last Reviewed: November 19, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.