How can I tie the execution of an MSI with an enclosing Wrapper?

Problem

How can I tie the execution of an MSI with an enclosing Wrapper?

Design Considerations

Pragmatically

Product Support and Administrators need the capacity to operate MSIs from the command line so there’s never been a need for MSI users to exclusively tie an MSI to a wrapper. One should observe that any manipulation done in the package can be altered by a savvy person and removed.

Solution

Typically this is solved with a simple LaunchCondition. Here's how one can add this using the tools in the Windows Installer SDK. Third-party package tools may have other solutions so check with your package vendor (of course, that is if you are using one ;^). Note: this is intended to allow the installation if launched from the wrapper, or if it has already been installed - thus allowing maintenance (modify, repair, update, uninstall) operations without having to use the wrapper.

Task 1: Open the Windows Installer File by Using the Orca Editor

To open the MyApp.msi file and to add a launch condition by using Orca, follow these steps:

1. Start Orca. Note To download and to install Platform SDK (including Orca), visit the following Microsoft Web site: https://www.microsoft.com/msdownload/platformsdk/sdkupdate/ (https://www.microsoft.com/msdownload/platformsdk/sdkupdate/) 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.
2. On the File menu, click Open.
3. In the Open dialog box, locate the MyApp.msi file, and then click Open. Note This file is located in the MyApp\Debug folder.

Task 2: Add New Tables to the Windows Installer File

To add new tables such as the LaunchCondition table to the MyApp.msi file, follow these steps:

1. Under Tables in the left pane, the LaunchCondition table exists. If this tables does not exist, perform step 2 and step 3.
2. On the Tables menu, click Add Table.
3. In the Add Tables dialog box, click to select the check boxes for LaunchCondition, and then click OK.

Task 3: Set Launch Conditions in the Windows Installer File

You can establish the launch condition based on a property. To set the launch condition in your MyApp.msi file, follow these steps:

1. Under Tables in the left pane, click LaunchCondition, and then click Add Row on the Tables menu.
2. In the Add Row dialog box, click Condition in the Name column, and then type WRAPPERCALLEDME OR Installed in the Condition - String[255], Required text box.
3. In the Name column, click Description, and then type Please launch [ProductName] through the wrapper. in the Description - Localizable String[255], Required text box.
4. In the Add Row dialog box, click OK.
5. On the File menu, click Save, and then close Orca.

Task 4: Verify That Your LaunchCondition Works

To test your application, follow these steps:

1. Locate the MyApp.msi file on your computer.
2. Right-click MyApp.msi, and then click Install. You should receive the message and the installation should error out: Please launch [ProductName] through the wrapper.
3. Open a command shell and run msiexec /i MyApp.msi WRAPPERCALLEDME=1, and the install should complete as if the LaunchCondition were not present
4. Open a command shell and run msiexec /x MyApp.msi, and the uninstall should complete as if the LaunchCondition were not present.

Now all you have left to do is add the WRAPPERCALLEDME=1 command line value the invocation of MyApp.msi from your wrapper.

Content credit also belongs to

  • Stefan, MSI MVP. You can get other Stefan insights about developing for Windows Installer from InstallSite

[Author: Robert Flaming and Editorial Support: Stefan Krueger]

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.

Comments