Tip: How to run an MSI installation from script

 
There is one script command available in Visual Installer's scripting language that can be used to run an MSI installation (a Windows Installer installation) during Visual Installer's setup process. The name of the command is MSIEXEC and it takes the following three parameters:
  
MSIEXEC   %Filename, %Param, %Wait
     
%Filename Complete path to the MSI file, for example %DESTDIR\MySetup.msi.
%Param Command line parameters to send to Windows Installer. Optional.
%Wait Wait until the MSI installation is completed, or not. Optional.
 
The %Filename parameter must always be specified and must contain a full path to an MSI file. The %Param and %Wait parameters are optional and you can omit them if you don't need them. These two parameters are explained in detail below:

 
n More information about the %Param parameter
Via
the %Param parameter you can send command line parameters (switches) to Windows Installer. A complete list with possible parameters is available on this Microsoft page, but some useful parameters are the following (they specify which type of user interface to show when the MSI installation runs):
 
/qn Runs a silent installation (no setup dialog boxes or messages are shown during the setup).
/qb Shows a reduced user interface, only shows how the installation proceeds.
/qf Shows a full user interface, with complete setup dialog boxes and error messages etc.
 
The
MSIEXEC script command calls the MSIEXEC.exe program, so all parameters that the MSIEXEC.exe program can handle can also be sent via the %Param parameter. MSIEXEC adds automatically the /i command line parameter when it runs MSIEXEC.exe (if you have not specified it) so you can omit /i if you want. /i tells Windows Installer to make a normal installation.
 
Exceptions are if you specify the /a (administrative installation) or /x (uninstall) parameter, then the /i parameter will not be added because only one of these parameters are allowed to exist on the same time. Read more about the MSIEXEC.exe program, and its parameters, on this page on our website.
 
n More information about the %Wait parameter
Sometimes it is necessary to pause Visual Installer's setup process until the MSI installation is completed. If you want Visual Installer to wait until the MSI installation is ready, you can set the third parameter (the %Wait parameter) to WAIT or 1. If you set this parameter to 0 or does not specify it at all, Visual Installer will continue its own installation immediately after it has started the MSI installation. The MSI installation will run parallel with Visual Installer's installation.
 
 
Examples of usage - MSIEXEC:
 
The example below installs MYSetup.msi. The installation runs parallel with Visual Installer's
own installation. The installation is run silently (no user interface is shown).
 
MSIEXEC %DESTDIR\MySetup.msi, /qn
 
The example below installs MYSetup.msi. Visual Installer pauses its own installation until the installation of MYSetup.msi is completed. A full user interface, with setup dialog boxes etc., is shown for the end-user.
 
MSIEXEC %DESTDIR\MySetup.msi, /qf, WAIT

The example below first installs MYSetup1.msi and thereafter, when the installation of MYSetup1.msi is completed, it installs MySetup2.msi. When the installation of MySetup2.msi is completed, Visual Installer continues its own installation. All installations are run silently.
 
MSIEXEC %DESTDIR\MySetup1.msi, /qn, WAIT
MSIEXEC %DESTDIR\MySetup2.msi, /qn, WAIT

If the installation of the MSI file takes long time, it can be useful to display an information message to the user. In Visual Installer's scripting language there is a command with the name
MESSAGE that can be used for this purpose. The example below shows how to combine the MESSAGE command with the MSIEXEC command:
 
// Run installation #1
MESSAGE
"Installs MySetup1.msi"
MSIEXEC %DESTDIR\MySetup1.msi, /qn, WAIT
 
// Run installation #2
MESSAGE "Installs MySetup2.msi"
MSIEXEC %DESTDIR\MySetup2.msi, /qn, WAIT

Sometimes different setup files must be run depending on the operating system. By combining the statements for conditional execution with the
MSIEXEC command, you can achieve this. Example:
 
// Run this installation only in Windows 8 or newer
IF OS=>WIN8
  MSIEXEC
%DESTDIR\MyWin8Setup.msi, /qn, WAIT
END IF
 
// Run this installation only in Windows 7 or older
IF OS<WIN7
  MSIEXEC
%DESTDIR\MyOldWinSetup.msi, /qn, WAIT
END IF
 
The script code above entered in the script window:
  

MSIEXEC
 
   
 
Uninstallation

The files that you installed using the MSIEXEC script command can be uninstalled during Visual Installer's uninstallation process by using another script command. We will explain more on this page.
 
   
  
See also
Visual Installer's Scripting Language
How to create a silent installation
 
   

< Tips Index Page
   

Go to Visual Installer product page Visual Installer Tip
 
Only Professional Version
SamLogic