Run Script attributes

The Run Script action runs one of the following script types:

This allows you to execute a series of external programs as a single action.

The Run Script action writes the script that you specify to a temporary file, then uses the appropriate program on the target system to execute the script. For Windows 95, 98, and Me, the default command processor for batch commands is COMMAND.COM; for Windows NT4, 2000, XP, and later it is CMD.EXE. However, if the user has an alternate command processor installed, for example 4DOS or 4NT from JP Software, it will be used instead. For VBScript and JScript scripts, WSCRIPT.EXE will be used.

Attributes

This pane contains the following attributes and options.

Attribute Description
Action name Enter the name of the action. This name is only used in InstallMate and is not visible to the user.
Description Enter the localizable description of the action. This description is displayed in progress messages in the installer while the action is executing.
Commands

Enter the commands that you want to execute in the script file. The command syntax depends on the script type; see Script below.

For MS-DOS batch files, you can use internal command processor commands such as COPY and DEL, or any external commands. Please be aware that the internal command options may differ somewhat between COMMAND.COM and CMD.EXE, so either use options that are available on all platforms, or create separate Run Script actions with Platforms settings (below) for Windows 95/98/Me in one, and Windows NT4/2000/XP/2003/Vista/2008 and later in the other.

Tip: If you want to use input or output redirection (<, >, or >>), be sure to place spaces on both sides of the redirection character to prevent InstallMate from interpreting them as symbolic variable references. Alternatively, surround them by `backticks`; this is also useful in VBScript and JScript expressions that use the <> character sequence: encoding this as `<>` prevents the installer from interpreting the brackets as an empty symbol reference. The backticks are removed before the script is passed to the script processor.

Start in

Enter folder path from which the script must be run, or click ... (browse) to open the Select Installation Folder dialog box that allows you to select a folder.

Prompt

Check this box and enter the localizable prompt text to have InstallMate prompt the user before the action is run; clear it to run the action without prompting.

If you use this option, then the prompt is displayed in a dialog box with (localized versions of) Yes and No buttons. The action is executed if the user clicks Yes and skipped if No is clicked. You should phrase your prompt accordingly.

Condition

Enter the conditional expression that determines if the action will be executed, or leave empty for unconditional execution.

Platforms...

Click this button to open the Select Installation Platforms dialog box that allows you to select the Windows versions on which the action must be executed. This platform selection acts as an additional condition for the action.

Disabled Check this box to disable the action. A disabled action is not included in the installer and not checked during the build. You can use this option to remove actions temporarily from your installer without permanently deleting them. Disabled actions are shown with a grayed-out icon.
Script

Select the desired script type from the drop-down list. The following choices are available:

Script Description
Batch Cmds MS-DOS commands that are executed by the %COMSPEC% processor on the target system.
VBScript A VBScript program that is executed by the wscript.exe processor on the target system.
JScript A JScript program that is executed by the wscript.exe processor on the target system.
PowerShell A series of Windows PowerShell commands that are sent to the PowerShell processor on the target system.
Execute

Select the action's execution mode from the drop-down list. The following choices are available:

Execute Description
Immediate Execute the action when encountered in the action sequence. This is the default.
Commit Defer execution until the installation is committed. This option allows you to implement the "Commit" part of a two-phase commit protocol that is only executed if the installation was successful.
Rollback Defer execution until the installation is rolled back. This option allows you to implement the "Rollback" part of a two-phase commit protocol that is only executed if the installation fails and must be rolled back.
Show

Select the desired visibility of the script process from the drop-down list. The following choices are available:

Show Description
Normal Show the script processor's window normally.
Minimized Show the script processor's window minimized (only on the taskbar).
Maximized Show the script processor's window maximized.
Hidden Hide the script processor's window. Use this option with caution; if the script requires user input, then the user will not be able to provide it and the script processor will hang until it is terminated by the user or the system.

Note: This option only has effect on the script processor's own windows; it does not affect any secondary programs that are started by the script.

Process 2

Enter the name of a secondary process to wait for, or leave empty to wait only for the script processor. This option only has effect if Time out is checked. It is useful if the script starts a secondary program and the script processor itself does not wait for those programs to terminate (this is the case with batch commands, for example; they only wait for the GUI program to start its message loop and process the initial messages, unless you use the start /wait command).

Time out

Check this box and enter the time-out period in seconds to execute the action synchronously; clear it to execute the action asynchronously. If the action is executed synchronously, the installer will wait for it to complete; for an asynchronous action, the installer starts the action and then immediately continues.

Note: If the time-out period expires before the script processor terminates, the installer continues with its next action. However, the script processor itself is not terminated; it will remain active in the background until it terminates of itself or is forcefully terminated by the user or the system.

Not silent

Check this box to skip the action if the installer is running in silent mode (/q command line option; TsuQuiet > 0); clear it to run the action in all modes.

Hide installer

Check this box to hide the installer's main window while the action runs; clear the box to keep the installer's window visible.

Note: This option only has effect if the action runs synchronously, i.e., with the Time out option selected. During asynchronous actions, the installer remains visible.

Exit codes

For synchronous actions (see Time out above), the installer stores the script processor's exit code in the LastExitCode variable; you can use this variable in the conditions of subsequent actions. The exit code is one of the following:

  1. If an error occurs when the script processor is started, LastExitCode is set to the (nonzero) Windows error code.
  2. Else if the action terminates prematurely due to a time-out, LastExitCode is set to 259 (STILL_ACTIVE).
  3. Else if a secondary process is specified (see Process 2 below), its exit code is stored.
  4. Else the exit code of the script processor itself is stored.

For asynchronous actions, LastExitCode is set to 0 if the script processor was started successfully, or to a nonzero Windows error code if an error occurred while starting the process.

Note: LastExitCode is overwritten by the next action that runs an external program (including Run Script, Run DLL, Run Program, and Uninstall Product).

Related topics

Action Sequences, Working with attribute pane