HOW TO: Use Launch Conditions in a Microsoft Windows Installer Package (827021)
The information in this article applies to:
- Microsoft Windows Installer
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
- Microsoft Platform Software Development Kit (SDK) 1.0
SUMMARYThis step-by-step article describes how to use launch
conditions in a Microsoft Windows Installer package. You can establish launch conditions
in your Windows Installer package to quit the installation process and to display
a message if specific conditions are not satisfied. You set the conditions based
on the value of the property that the AppSearch tool returns. You can use AppSearch to
search for files, registry keys, folders, or Windows Installer
components during the installation of your Windows Installer package. If AppSearch locates the
item that you specified, AppSearch returns the search results as a
property. You can then evaluate this property in a launch condition. AppSearch uses the information that appears in database tables such as the following when it searches for files, registry keys, and folders: - Signature
- DrLocator
- RegLocator
- CompLocator
AppSearch returns its search results as a property value that is located in the AppSearch table. You set launch conditions in the LaunchCondition table based on this property value. The LaunchConditions action queries the LaunchCondition table and evaluates each conditional statement that is in the table. If
any of these conditional statements fail, you receive an error message
and the installation is not completed. You can use a table editor tool such
as Orca to create or to edit database tables in Windows Installer
packages. This article describes how to search for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Primary Interop Assemblies registry key while you are installing the Windows Installer package. This article also describes how to quit the installation process if the registry key does not exist on your
computer. The steps in this article describe how to use Orca to modify the Windows Installer (.msi) file and to set
the launch condition. back to the
topRequirementsThis article assumes that you are familiar with the following topics: - Visual Studio .NET Setup Projects
- Orca.exe
- AppSearch
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need: - Microsoft Windows 2000, Microsoft Windows XP, or Microsoft
Windows Server 2003
- Microsoft Visual Studio .NET
- Microsoft Platform Software Development Kit
(SDK)
back to the topCreate a Microsoft
Windows Installer Package by Using Microsoft Visual Studio
.NETTo create a Windows Installer package by using Microsoft Visual
Studio .NET, follow these steps:
- Start Microsoft Visual Studio .NET.
- On the File menu, point to
New, and then click Project.
- Under Project Types, click
Visual Basic Projects.
- Under Templates, click
Windows Application, and then click
OK. By default, Form1 is created.
- Add a Button control
to Form1.
- Paste the following code in the Button1_Click event handler:
MessageBox.Show("This is a test Windows Installation package") - On the Build menu, click Build
Solution.
- On the File menu, point to Add
Project, and then click New Project.
- Under Project Types, click
Setup and Deployment Projects.
- Under Templates, click
Setup Project.
- In the Name text box, type
MyApp, and then click OK.
- In Solution Explorer, right-click MyApp,
point to Add, and then click Project
Output.
- In the Add Project Output Group dialog
box, click OK.
- In Solution Explorer, right-click MyApp,
and then click Build.
back to the
topOpen the Windows Installer File by Using the Orca EditorTo open the MyApp.msi file and to add a launch condition by using Orca, follow these steps: - Start Orca.
Note To download and to install Platform SDK (including Orca), visit the
following Microsoft Web site: After you install Platform SDK, install Orca. To do this, double-click the
Orca.msi file that is located in the Bin subfolder of the Platform SDK installation folder. - On the File menu, click
Open.
- In the Open dialog box, locate the
MyApp.msi file, and then click
Open.
Note This file is located in the MyApp\Debug folder. back to the
topAdd New Tables to the Windows Installer FileTo add new tables such as the AppSearch table, the RegLocator table, and the LaunchCondition table to the MyApp.msi file, follow these steps: - Under Tables in the left pane, verify
whether the AppSearch table, the
LaunchCondition table, and the RegLocator
table exist. If these tables do not exist, perform step 2 and step 3.
- On the Tables menu, click Add
Table.
- In the Add Tables dialog box, click to
select the check boxes for LaunchCondition, AppSearch, and
RegLocator, and then click OK.
back to the topUse AppSearch in the Windows Installer FileAppSearch searches for a registry key based on the
information that appears in the RegLocator table. AppSearch also sets the property in the AppSearch table while you are installing the Windows Installer package. To use AppSearch to search
for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Primary Interop Assemblies registry key on your computer, you must provide the search
information in the RegLocator table. To do this, follow these steps: - Under Tables in the left pane, click
RegLocator, and then click Add Row on the
Tables menu.
- In the Add Row dialog box, click
Signature_ in the Name column, and then type
REGKEY12345 in the Signature_ - String[72],
Required text box.
- In the Name column, click
Root, and then type 2 in the
Root - Short, Required text box.
- In the Name column, click
Key, and then type
SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Primary Interop
Assemblies in the Key - String[255], Required text box.
- In the Add Row dialog box, click
OK.
- Under Tables in the left pane, click
AppSearch, and then click Add Row on the
Tables menu.
- In the Add Row dialog box, click
Property in the Name column, and then type
REGISTRYVALUE1 in the Property - String[72],
Required text box.
- In the Name column, click
Signature_ , and then type REGKEY12345
in the Signature_ - String[72], Required text box.
- In the Add Row dialog box, click
OK.
back to the topSet Launch Conditions in the Windows Installer FileAppSearch searches your computer for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Primary Interop Assemblies registry key, and then returns the search results as a property value that is located in the AppSearch table. You can establish the launch condition based on this
property. To set the launch condition in your MyApp.msi file, follow these steps:
- Under Tables in the left pane, click
LaunchCondition, and then click Add Row on
the Tables menu.
- In the Add Row dialog box, click
Condition in the Name column, and then type
REGISTRYVALUE1 in the Condition - String[255],
Required text box.
- In the Name column, click
Description, and then type The Primary Interop Assemblies registry key does not exist. in the
Description - Localizable String[255], Required
text box.
- In the Add Row dialog box, click
OK.
- On the File menu, click
Save, and then close Orca.
back to the topVerify That Your Application WorksTo test your application, follow these steps: - Locate the MyApp.msi file on your computer. This file is located at MyApp\Debug folder.
- Right-click MyApp.msi, and then click
Install. If your computer does not have the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Primary Interop Assemblies registry key, you receive
the following message and the installation is not completed:The Primary Interop Assemblies registry key does not exist.
back to the
topREFERENCES
For additional information, click the following article numbers to view the
articles in the Microsoft Knowledge Base: 307353
HOW TO: Create a Setup Package by Using Visual Studio. NET
307374 HOW TO: Use Launch Conditions in Visual Studio .NET
For more information about launch conditions,
visit the following Microsoft Developer Network (MSDN) Web
site: back to the
top
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbPackage kbHOWTOmaster kbhowto kbSDK kbtable kbsetup kbDeployment KB827021 kbAudDeveloper |
---|
|
|
©2004 Microsoft Corporation. All rights reserved.
|
|