How to run a program or open a document via script

In the previous two blog posts we described how to run a program or show a document after an installation, when running a setup package created with Visual Installer. It is also possible to run a program or open a document via Visual Installer´s script language.

One benefit of using script for running a program or opening a document is that you can use a conditional check before you run/open the file. You can for example run different versions of a program depending on which operating system the installation is run in. For example:

// Run only in Windows 10
IF OS=WIN10
  RUN %DESTDIR\MyWin10App.exe
END IF
 
// Run only in Windows 11
IF OS=WIN11
  RUN %DESTDIR\MyWin11App.exe
END IF

  
In the same way you can open and show a particular document based on a condition. For example:

// Open and show only in Windows 10
IF OS=WIN10
  SHOW_AFTER %DESTDIR\For_Win10_Users.pdf
END IF
 
// Open and show only in Windows 11
IF OS=WIN11
  SHOW_AFTER %DESTDIR\For_Win11_Users.pdf
END IF

  
The RUN command above (example 1) is executed immediately and the SHOW_AFTER command above (example 2) is executed when the installation is completed. Read more below.
  
Script commands in Visual Installer that run programs
These three script commands can be used to run programs during an installation:

RUN : Runs a program.
XRUN : Runs a program – with additional options.
RUN_AFTER : Runs a program – when the installation is completed.

  
Script commands in Visual Installer that open documents
These two script commands can be used to open documents during an installation:

SHOW : Opens a document.
SHOW_AFTER : Opens a document – when the installation is completed.

  
The RUN, XRUN and SHOW commands are executed immediately, when the script line is executed, but the RUN_AFTER and SHOW_AFTER commands delays it execution till the installation is completed and the last setup dialog box has been closed.

The RUN_AFTER and SHOW_AFTER commands are new commands that were included in version 12.0.10 of Visual Installer (read more).

See also
> How to run a program after an installation
> How to show a document after an installation