Creating Nested Installs

book

Article ID: 180610

calendar_today

Updated On:

Products

Symantec Products

Issue/Introduction

 

Resolution

Problem
How to create a Nested Installation with an .MSI embedded into the main .MSI and Uninstall with a Custom Action.

Environment

 

Cause

Resolution

Errors can result when one .MSI is called during the ExecuteImmediate sequence of a second .MSI because the Windows Installer service normally only allows one .MSI installation to execute at a time. To work around this limitation, you can design a nested installation. Nested installations enable you to conveniently run a Windows Installer installation that is already advertised or installed on the destination machine from within your main .MSI installation.

Before you create this nested installation, you must have a main installation file and the nested installation file accessible from the destination machine. In this article, you first create two .MSI installations, Other.MSI and Main.MSI. Next, you create the custom action to set up the nested installation. Then you create a custom action for the uninstall. When the Main.MSI runs, it will call the Other.MSI file.

Note: You can use two .WSI files instead through this process with the nested file needing to be compiled prior to adding the Custom Action in the main .WSI project file.

To create two .MSI files for a nested installation:

  1. Open Wise for Windows Installer, Wise for Visual Studio .NET, or Wise Package Studio. If you are working in Wise Package Studio, open the Windows Installer Editor tool.
  2. Select New from the File menu. The New Installation File dialog appears.
  3. Select the Windows Application icon, then click OK.
  4. Fill in the Product Details page in Installation Expert with information about your installation.
  5. On the Files page in each .WSI, add at least one file to the installation.  (Every .MSI needs to have at least one component in the package in order to avoid getting a Windows Installer error).
  6. Save your file with the name Main.WSI. Compile Main.WSI into Main .MSI.
  7. Follow steps 2 through 5 to create another .MSI file and name the next .WSI Other.WSI and compile it into an .MSI .
  8. On the Product Details page, copy the product code listed in the Product Code field to Notepad.
  9. Save this installation file with the name Other.MSI.

To create a custom action for the nested installation:

  1. Open the Main.MSI installation.
  2. Click No in the message to convert your .MSI to a .WSI file.
  3. Click the MSI Script tab, then click the Execute Immediate tab.
  4. Scroll down to the Cost Finalize script line in the Installation Sequence pane. It's the last line in the fifth section of script.
  5. Select the blank line below the Cost Finalize action then double-click the Install MSI from Installation action in the Actions pane. The Install MSI from Installation dialog appears.
  6. Fill in the fields as follows:
         Custom Action Name: Enter a name for this custom action.
         Installation to Run: Enter the path to the Other.MSI file.
         Leave the Property Settings field blank.
         Click OK.
  7. Double-click the If Statement action in the Actions pane. The If Settings dialog appears.
  8. Enter Not Installed in the If Condition field, then click OK.
  9. Select the blank script line below your new custom action.
  10. Double-click the End Statement action in the Actions pane.

To create a custom action for the uninstall:

  1. Scroll down to the REM. Begin the sequence of actions that makes changes to the system script line, which is seven lines below the End statement you added to your script.
  2. Select this script line then double-click the Install MSI from Destination action in the Actions pane. The Install MSI from Destination dialog appears.
  3. Fill in the fields as follows:
         Custom Action: Enter the name of the custom action.
         Product Code: Copy and paste the Other.MSI product code from the Notepad file.
         Property Settings: Enter REMOVE=ALL
         Click OK.
  4. Double-click the If Statement action in the Actions pane. The If Settings dialog appears.
  5. Enter REMOVE~="ALL" in the If Condition field, then click OK.
  6. In the Installation Sequence pane, select the line below the Install MSI from Destination Product Code that you created.
  7. Double-click the End Statement action in the Actions pane.
  8. Save and compile the Main.MSI installation.

To test your installation:

  1. Click the Run button to run the Main.MSI installation.
  2. Confirm the Main.MSI and Other.MSI files have been installed.
  3. Click on the Start button on the taskbar and select Settings > Control Panel.
  4. Select Add or Remove Programs and in the Add or Remove Programs panel, uninstall Main.MSI.

You now have a working nested installation and uninstall custom action in your installation. When you are running a nested installation, you cannot modify the directory where Other.MSI installs the application. When you browse for the directory, it only changes the location of Main.MSI.

Optionally, you can force the state of the main installation to track the state of the nested installation. To do this, modify the property settings in the installation following the steps below:

  1. Open the main installation then click the MSI Script tab.
  2. Double-click the existing Install MSI from Installation script line in the Installation Sequence pane. The Install MSI from Installation dialog appears.
  3. In the Property Settings field, enter ALLUSERS=[ALLUSERS], then click OK.
    The nested installation becomes per-machine if the main installation is per-machine, and the nested installation becomes per-user if the main installation is per-user.

If you want to run a nested installation from a relative path, make sure the following conditions are true.

  • The main .MSI file cannot be an .MSI file that is wrapped with an .EXE file.
  • The nested installation must be in a sub-directory of the main .MSI file.