How to create a customized .EXE wrapper for .MSI within WiseScript

Article:HOWTO8661  |  Created: 2008-03-04  |  Updated: 2010-11-11  |  Article URL
Article Type
How To


How do I create a customized .EXE wrapper for an ..MSI within WiseScript?


 Using WiseScript Wrappers to Perform Multiple Tasks

WiseScript is extremely versatile and can be adapted for a wide variety of purposes. One common application uses a WiseScript to execute several script-based and Windows Installer (.MSI) installations. These scripts, referred to as “wrapper scripts,” allow one or more installations to be wrapped into a single script. The single script can perform additional tasks such as executing other utilities, running batch files, and installing prerequisite software or runtime engines.

Several common issues can appear when creating wrapper scripts, and you can use WiseScript actions to address these common issues. This article answers common questions that arise when creating installation wrappers with WiseScript. To follow the questions and answers below, open your installation in Wise Installation System, WiseScript Editor in Wise Package Studio, or in WiseScript in Wise for Windows Installer and Wise for Visual Studio .NET.

How do I execute installations within a wrapper script?

Within the wrapper script, use the Execute Program script action to run other WiseScript .EXE installations or .EXE files. To accomplish this, follow the procedures below.

  1. In the Script Editor, double-click the Execute Program script action. The Execute Program Settings dialog appears.
  2. In the Executable File field, enter the full path name and executable of the file to run.
  3. In the Command Line Arguments field, enter any command line switches to pass to the .EXE.
  4. Mark the Wait for Program to Exit check box if the wrapper script should wait for the .EXE to finish before continuing with the remainder of the wrapper script. If return values from the .EXE are expected, mark this check box.
  5. Enter values in the Default Directory, Variables Added, and Window Size fields as appropriate. For more information on these fields, please see the topic titled ‘Execute Program’ in the Wise online help.

If you are using the Execute Program script action to launch an .MSI installation instead of an .EXE, configure the action as follows.

  1. In the Executable File field in the Execute Program dialog, enter %SYS%\msiexec.exe.
  2. In the Command Line Argument field, enter the parameters to perform the action on the .MSI. For an initial installation of an .MSI file, enter

    /I “PathToMSI.msi”

  3. To have the WiseScript wrapper to wait for the .MSI installation to finish, mark the Wait for Program to Exit check box.

Handling return values within a wrapper script

To obtain the return value from an Execute Program action, use the PROCEXITCODE WiseScript variable. This variable is automatically defined after each Execute Program script action and contains the return value from that .EXE. Although this variable is automatically defined, it must still be initialized before it is used in the WiseScript wrapper. To initialize the variable, use the Set Variable script action and set the PROCEXITCODE to any value.

Using this return value enables scripting of various courses of action depending on whether the called installation succeeded, failed, or returned any other status.

Handling reboots within a wrapper script

Installations often require the system to reboot before proceeding. If any of the installations called from the wrapper script require a reboot, the main wrapper script must handle this for the installation to continue after the system restarts. Two possible methods for rebooting with the wrapper script are listed below.

Rebooting with a wrapper script: Option 1

Place a shortcut to the WiseScript wrapper .EXE in the StartUp folder so it launches after a reboot. Next, use internal script logic to determine exactly where execution of the wrapper script occurs after each reboot. 

For example, suppose a wrapper script installs two packages, Package1 and Package2. Include checks to see if each package is installed and, if so, then skip those installations and continue until all installations finish executing. There are several ways to determine if packages are installed.

  • Invoke the Check If File/Dir Exists script action to verify whether a specific file exists, and use this to indicate whether the installation was successful.
  • Use the Get Registry Key Value script action to check for a specific registry value from the Package1 and Package2 installations.
  • Use and validate a counter that is incremented by the wrapper script before each installation executes.

Use the information gathered from the check to construct conditional statements to control the execution of the Package1 and Package2 installations. Below is some “pseudo code” of how these statements look. 

Create Shortcut in StartUp folder to WiseScript Wrapper EXE
Check if Package1 is installed
If Package1 is NOT Installed Then
      Execute Program to install Package1
End Statement
Check if Package2 is installed
If Package2 is NOT Installed Then
      Execute Program to install Package2
End Statement
Delete Shortcut in StartUp folder

Rebooting with a wrapper script: Option 2

Populate the value of the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce registry key with the path to the WiseScript wrapper executable and pass it different command line parameters to mark the position where execution continues in the wrapper script if a reboot occurs. In the wrapper script, check the %CMDLINE% variable to obtain the command line switches that are passed in and to create conditional statements based on this value. Below is “pseudo code” for an example of a WiseScript wrapper that installs three packages.

Set Variable POS = 0

If %CMDLINE% Contains “/POS” Then
      Rem Parse everything after /POS into a variable POS
Parse String "%CMDLINE%" into JUNK and POS
Rem Parse %POS% to obtain the next character into POS
Parse String "%POS%" into POS and JUNK
End Statement

If %POS% Less Than or Equal “1” Then
Write RunOnce Key = “PathToWrapper.EXE /POS2”
Execute Program to install Package1
End Statement
If %POS% Less Than or Equal “2” Then
Write RunOnce Key = “PathToWrapper.EXE /POS3”
Execute Program to install Package2
End Statement
If %POS% Less Than or Equal “3” Then
Execute Program to install Package3
End Statement
Remove RunOnce Key

Option 1 and option 2 are two very common methods for tracking the progress of your WiseScript wrapper script across multiple reboots. There are many other options available as well. Keep in mind that when a specific installation requires a reboot, no return value is likely to be passed back to the WiseScript wrapper because of the reboot. To verify the success of an installation, perform any checks after the reboot has occurred.

In addition to performing installations, a WiseScript wrapper can handle any installation prerequisites. For example, a WiseScript wrapper can pre-install specific runtimes or make changes to the system configuration before initiating installations.

The wide range of script actions available with WiseScript allows the script to perform a variety of tasks including performing installations, modifying system configurations, running utilities, handling potential errors and reboots, and verifying all installation tasks have been completed. With this type of versatility, WiseScript automation can be used for almost any set of tasks.

Legacy ID


Article URL

Terms of use for this information are found in Legal Notices