MSI Silent Mode Installations for InstallScript MSI Projects

InstallShield DevStudio

If you need to silently install an InstallScript MSI project without using Setup.exe, you can use the MSI silent mode.

Launching MSI Silent Installations for InstallScript MSI Setups

The MSI silent installation is launched in the following cases:

  • The installation is launched at the command line by typing msiexec product.msi /qn.
  • The installation is activated from an advertised shortcut.
  • The installation is activated from install-on-demand.
  • When the product is removed when an update package is running.

Unlike the traditional silent mode, the MSI silent mode does not follow the regular logic provided through script. It simply runs through the InstallExecuteSequence table. (To see this table, navigate to the Direct Editor.) As a result, some events are not fired, including the following:

  • All UI installation events—OnFirstUIBefore and OnFirstUIAfter
  • All Feature events

The OnMsiSilentInstall Event

What the Event Does

In an InstallScript MSI project installation, InstallShield DevStudio runs the OnMsiSilentInstall event handler if the product is not already installed on the target system. This happens if the installation is launched by msiexec product.msi /qn or if the installation is activated from an advertised shortcut.

You need to override the OnMsiSilentInstall event if you want to support the MSI silent installation mode. This allows you to perform tasks that are normally performed in the OnFirstUIBefore, OnFirstUIAfter, and feature event handlers.

Overriding the Event

By default, OnMsiSilentInstall displays a message and then aborts the installation. You can override this event handler by writing your own implementation of the function. The prototype of this function is as follows:

external prototype OnMsiSilentInstall(HWND hInstall);

where hInstall is the handle to the installation.

The simplest thing you can do is to implement an empty body of this event so installation will not abort, as:

function OnMsiSilentInstall(hInstall)
begin
	//Do nothing and allow installation to continue.
end;

Again, OnMsiSilentInstall will be fired on MSI silent installation and on activation of an advertised shortcut. It will not be fired on Install-On-Demand, auto-repair, and uninstall mode.

Using MsiExec.exe Directly

If you want to use MsiExec.exe directly, you need to first use MsiExec.exe to install ISScript.msi (unless you are certain that the latest script engine files are available on the target system). You can do this by typing MsiExec.exe /qn /i ISScript.msi at the command line.

Detecting the Mode in which a Silent Install is Running

To detect whether a traditional silent install is running from InstallShield script, use

if (MODE = SILENTMODE)

To detect whether an MSI silent mode installation (including /q, advertise, auto-repair, uninstall, or install-on-demand) is running from InstallShield script, check the MSI property "ISSETUP_UISEQUENCE_PROCESSED" using the MsiGetProperty Windows Installer API function. If this property is not set, then it is a silent install. (It indicates that the InstallUISequence is not executed.)

See Also

Silent Installations

MSI Silent Mode Installations for InstallScript MSI Projects

posted on 2008-01-21 14:25  Joey Liang  阅读(1282)  评论(0编辑  收藏  举报