Installing MSI Files

There are some special cases when you will have to silently install and .msi file to make your portable work. This .msi file is not the main setup file of the software, it only installs an additional feature that must be present on the local computer for the portable to run. You should use it with care because it may install older files on the host computer, overwriting newer version of them.

To install an .msi file silently, use this code:

ExecWait ‘MSIEXEC.EXE /i “$EXEDIRAppdatamsiMicrosoft_VC80_MFC_x86.msi” /qn /norestart’ $0

Because this it may take some to time to finish, it is better to use ExecWait instead of Exec. Of course, you can add some extra waiting with the sleep command (i.e. Sleep 500) but it should work without it also.

To see what switches are available, double-click on “WindowsSystem32msiexec.exe”.

ExecWait ‘MSIEXEC.EXE /x “$EXEDIRAppdatamsiMicrosoft_VC80_MFC_x86.msi” /qn /norestart’ $0

Because you don’t know whether the msi package is installed on the host computer or not, use it only in cases if you’re 100% sure it can be removed without any harm. However, I had to install an .msi file only one time so far (out of some hundred portables). If you’re unsure, I recommend you not to uninstall it. It’s still better if an earlier version remains on the host PC than no version at all.

Note: in this guide I used “Exec” or “ExecWait” every time I wanted to launch an application. But in some cases you have to use “ExecShell” to launch a file. The NSIS Help says about ExecShell:

4.9.1.3 ExecShell

action command [parameters] [SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED | SW_HIDE]

Execute the specified program using ShellExecute. Note that action is usually “open”, “print”, etc, but can be an empty string to use the default action. Parameters and the show type are optional. $OUTDIR is used for the working directory. The error flag is set if the process could not be launched.


Note: If you want to launch an exe file, Exec or ExecWait will do. But if you want to open (or whatever the default action is associated with that file type) other files such as bitmaps, text documents, etc, you should use ExecShell (Exec or ExecWait won’t work in these cases).
Previous

One response to “Installing MSI Files”

  1. wilsont3ch.com » How To Make Portables

    [...] 9. Installing MSI Files [...]