Run Program attributes (Tarma)

Reference information
Project page Action Sequences, Installer Dialogs
Related topics Working with attribute panes

Introduction

The Run Program action runs an external program or opens an document file through its Windows Shell association. You can also use it to open a web page or anything else that the Windows Shell knows how to handle.

MSI note The Windows Installer equivalent is Run Program, although it does not have all the options of the Tarma Installer version.

Exit codes

For synchronous actions (see Time out below), the installer stores the external program'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 program 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 program itself is stored.

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

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

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 Tarma ExpertInstall 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.
Target path

Enter the path to the program to run or document file to open, or click ... (browse) to open the Select Installation File or Folder dialog box that allows you to select a file.

To open a web page, specify the fully qualified URL including the protocol specifier, for example http://www.tarma.com/. You can also enter any other path or protocol that the Windows Shell on the target system knows how to handle.

Start in

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

Arguments

Enter the arguments for the program. Be sure to enclose any arguments that contain (or might expand to contain) spaces in quotes, for example "argument with spaces" or "<INSTALLDIR>".

Prompt

Check this box and enter the localizable prompt text to have Tarma Installer 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.

Execute

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

Execute Description
Immediate Execute when encountered in the action sequence.
Commit Defer execution until the installation is committed. This option allows you to implement a two-phase commit scheme that only commits changes if the installation was successful.
Rollback Defer execution until the installation is rolled back. This option allows you to create rollback actions that are only executed if the installation fails and must be rolled back.
Show

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

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

Enter the name of a secondary process to wait for, or leave empty to wait only for the Target path process. This option only has effect if Time out is checked. It is useful if the external program starts a secondary program that must complete before the installer continues.

Note: If you specify a secondary process, then the Time out value applies to the total running time of both processes. Tarma Installer first waits for the Target path process; after it terminates, it then waits for the remainder of the Time out period until the secondary process terminates.

Exit code

Select the exit code handling from the drop-down list. The following choices are available:

Exit code Description
Ignore Ignore the program's exit code.
Fail if nonzero Terminate the parent action sequence and the fail the installation if the program's exit code is nonzero.
Fail if zero Terminate the parent action sequence and the fail the installation if the program's exit code is zero. This option is not recommended, because the exit code may be zero if the external program runs asynchronously and is started successfully.

The effectiveness of this option depends on the way the external program is programmed. It is customary that successful completion of a program is indicated by an exit code of zero, and failure by a nonzero exit code. However, not all programs comply with this convention. Furthermore, the Run Program action itself may set a nonzero exit code if it cannot start the external program or if the time-out period expires before the program terminates (see Exit codes earlier in this topic).

Before you use the Exit code option, we recommend that you convince yourself that the external program in question returns an appropriate exit code. If you want to use the program's exit code to terminate the installation or control the execution of subsequent actions, we suggest that you set the Exit code option to Ignore and use one of the following alternative approaches:

  • To terminate the installation if the external program returns a nonzero exit code, insert a MessageBox action immediately after the current Run Program action. Set the MessageBox action's Condition to LastExitCode <> 0 and set its Fail mode to Fail if run. Enter an appropriate error message in its Message field.
  • To execute or skip any subsequent actions depending on the external program's exit code, use the conditional expressions LastExitCode = 0 or LastExitCode <> 0, respectively, in the subsequent actions. Please note that the LastExitCode variable will be overwritten by the next Run Script, Run Program, and Uninstall Product action.
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 external program terminates, the installer continues with its next action. However, the external program 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.

ShellExecute

Check this box to use the Windows ShellExecute function to run or open the external program or document file; clear it to run the program directly. This option is required if Target path specifies a non-executable file, for example a text file, HTML file, or web page. It is optional for executable files; in that case we recommend clearing this option.