Microsoft KB Archive/240998

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

Article ID: 240998

Article Last Modified on 6/11/2002

-

APPLIES TO


 * Microsoft Office 2000 Developer Edition

-



This article was previously published under Q240998



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

IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry



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: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  Start Notepad and type the following text:   REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce] "RunCalculator"="Calc.exe"  On the File menu, click Save As. Browse to your Microsoft Office folder. In the Save As dialog box, click All Files in the Save as type list In the File name box, type Test.reg . Click Save, and then quit Notepad.

This example uses the Test.reg file as the registry file to add to the package.</li> In Access, open the sample database Northwind.mdb.</li> Press ALT+F11 to switch to the Visual Basic Editor.</li> On the Add-ins menu, if the Package and Deployment Wizard is listed, skip to step 13.</li> On the Add-ins menu, click Add-in Manager.</li> In the Available Add-ins list, click VBA Package and Deployment Wizard.</li> Under Load Behavior, click Loaded/Unloaded, and then click OK.</li> On the Add-ins menu, click Package and Deployment Wizard.</li> In the Package and Deployment Wizard dialog box, click Package.</li> Click Next and accept the defaults until you see the Package and Deployment Wizard - Included Files screen.</li> Make sure that the Include Access Runtime check box is selected.</li> Click Add and add the Test.reg file that you created in steps 1 through 6.</li> Click Next to move to the Package and Deployment Wizard - Registry Information screen.</li> On the line for Test.reg, make sure Copy File is set to No and Update Registry is set to Yes.</li> Continue through the wizard until it is finished, and then close the wizard.</li> Install the package onto a clean Windows computer (a computer that has a newly installed version of Windows, and no other applications).</li> <li>Restart the computer.</li></ol>

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: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.


 * 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: kbhowto kbpdwizard kbfaq KB240998

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.