How do I customize Windows Installer properties using Wise Script?

Article:HOWTO2158  |  Created: 2006-02-06  |  Updated: 2008-04-29  |  Article URL http://www.symantec.com/docs/HOWTO2158
Article Type
How To



Question

How do I customize Windows Installer Properties using WiseScript ?

Answer

Customizing installations by editing the Windows Installer tables is potentially dangerous and may not provide all the functionality necessary for your desired customizations. Directly editing the tables, when done incorrectly, could corrupt your installation. One way you can bypass these limitations is calling custom .dll files from within Windows Installer and passing multiple parameters to and from each .dll. However, this can be a tedious process. Fortunately, WiseScript provides scripting capability for your installation development and lets you easily retrieve and set Windows Installer properties, and evaluate WiseScript expressions to customize your installation.

This article explains the actions available from the WiseScript tool and provides an example that demonstrates the ability to pass information back and forth between Windows Installer and WiseScript during the installation.

Get Windows Installer Property

This action reads the value of a Windows Installer property set during installation and places it into a variable. On the Get Windows Installer dialog, you provide the name of the Windows Installer property value to retrieve and specify which WiseScript variable will hold the value. The Get Windows Installer Property script action initializes the WiseScript variable, so you do not need to initialize the variable with a Set Variable script action.

Set Windows Installer Property

This action sets a Windows Installer property to a defined value. On the Set Windows Installer dialog, enter a property name from the .MSI or .WSI. Then, enter a value to assign to the property. If you want to assign the value of a WiseScript variable to the property, use %VARIABLE%.

Evaluate Windows Installer Condition

This action evaluates a Windows Installer condition and places the value of the condition into a defined variable. This variable is set to 1 if true, or 2 if false. Use the Evaluate Windows Installer Condition action to perform an action based on a Windows Installer condition defined in the .msi. To use this action, utilize the same syntax of the condition's logic from the .msi and a variable.

Utilizing the power of WiseScript actions

This example demonstrates the ability to pass information back and forth between Windows Installer and WiseScript during the installation. You can use this particular example for parsing a directory path passed from a Windows Installer property and placing it into the registry.

To create a new Windows Installer package:

  1. Open Wise for Windows Installer, Wise Installation Express, or Windows Installer Editor in Wise Package Studio or Wise Installation Studio.
  2. Select New from the File menu. The New Installation File dialog appears.
  3. In the New Installation File dialog, select Windows application and the Create .WSI or .WSM project file that can be compiled into an .MSI or .MSM option.
  4. Open the Files page in Installation Expert.
  5. In the lower-left pane, select the Program Files folder and click the New Folder button. The Create New Folder dialog appears.
  6. In the New Folder Name field, type a name for the new folder, such as MyApplication.
  7. Add a file named Installation Test to the newly created folder.

To locate the Windows Installer property for the directory:

  1. In Setup Editor, click the Tables tab.
  2. Select the Directory table.
  3. In the DefaultDir column, locate the Installation Test folder that you created on the Files page. In this row, make sure INSTALLDIR appears in the Directory column.

To create the Custom Action that calls the WiseScript:

  1. Click the MSI Script tab, then select the Execute Immediate tab in the Installation Sequence pane.
  2. In the Installation Sequence pane, select the line to add the Custom Action. For this example, select the line after CostFinalize. Directory resolution occurs during the CostFinalize action.
  3. In the Actions pane, double-click Run WiseScript from installation. The Run WiseScript from Installation dialog appears.
  4. In the Run WiseScript from Installation dialog, type a name that defines the routine of your Custom Action in the Custom Action Name field. For this example, type ParseDirectory.
  5. Click the Options button and select Create New WiseScript. The Save As dialog appears.
  6. In the Save As dialog, browse to the location where you would like to save your WiseScript, then click Save. If you are using Wise for Windows Installer or Wise for Visual Studio .NET, WiseScript Express opens. If you are using Wise Package Studio, WiseScript Editor opens.

To copy the Windows Installer property into a WiseScript variable:

  1. In the WiseScript tool, double-click Get Windows Installer Property in the Actions list. The Get Windows Installer Property dialog appears.
  2. In the Get Windows Installer Property dialog, enter the following:

    Dest. Variable:
    Type the variable name that will hold the value. For this example, type DIRECTORY.

    Property Name:
    Type INSTALLDIR. This is the name of the property to retrieve.
  3. Click OK.

To parse the directory using the variable:

  1. In the Installation Script pane, select the line after the Get Windows Installer Property action.
  2. In the Actions list, double-click the Parse String action. The Parse String dialog appears.
  3. In the Parse String dialog, enter the following information:

    Source Value:
    Type %DIRECTORY%.

    Pattern/Position:
    Type \. This is the substring character where the parse will occur.

    Destination Variable 1:
    Type DIRECTORY. This replaces the original DIRECTORY variable with the characters from the beginning of the string to the backslash.

    Destination Variable 2:
    Type EXTRA. This places any characters right of the backslash in this variable.
    Operation. Select Split value at last occurrence of pattern from the drop-down list.
    This removes the last backslash of the variable DIRECTORY.
    Click OK.
  4. To add a second Parse String action, complete steps 2–3 again, but type new variable names in the Destination Variable 1 and Destination Variable 2 fields.

The first time through the steps, the Parse String action removes the trailing backslash, and the second time through, it removes the directory name. Although Windows Installer always adds a backslash at the end of a directory, it is not necessary to keep a trailing backslash in the WiseScript variable.

To set the Windows Installer property back to the .MSI:

  1. In the Installation Script pane, select the last Parse String action.
  2. In the Actions list, double-click Set Property. The Set Property dialog appears.
  3. In the Set Property dialog, enter the following information:

    Property Name:
    Type INSTALLDIRNEW.

    Property Value:
    Type %DIRECTORY%. This new value goes to the property.
  4. Click OK.
  5. Click the Compile button.
  6. Close the WiseScript tool.
  7. In MSI Script, click OK in the Run WiseScript from Installation dialog.

To write a registry key based on the new property:

  1. In Installation Expert, click the Registry page link.
  2. In the bottom-left pane, select the location where you want to create the new registry key.
  3. Click the Add button and select Key. The Registry Details dialog appears.
  4. In the Registry Details dialog, enter the following information:

    Operation:
    Select Create/Update key and value.

    Key:
    Enter the name of the key you want to create.

    Value Name:
    Enter the name of the key under which you want to create the directory.

    Data Value:
    Type [INSTALLDIRNEW]. This is the property you set in the WiseScript.

    Data Type:
    Leave the default of String. This places the directory into the registry.
  5. Click OK.

After completing the above steps, click Compile and run your script on a test computer. By following the above procedures, you can retrieve Windows Installer properties from the .msi, manipulate the data with a WiseScript, and send the information back to the .msi during installation. The example detailed above is useful when you need to trim backslashes from directories during the installation. You can also use this example as a springboard for ideas to customize and add power to your installation without directly editing the Windows Installer tables.


Legacy ID



19286


Article URL http://www.symantec.com/docs/HOWTO2158


Terms of use for this information are found in Legal Notices