Friday, March 09, 2007

Command-Lines

Windows Installer provides numerous command-line options and properties to customize the installation and management of an application. You can use multiple command-line options and properties simultaneously to get the result you want.
Syntax of Command-Line Options
The following is an implementation of the most commonly used command-line options:
The executable file for Windows Installer is msiexec.exe. To change the state of a Windows Installer–based application by using a command-line option, the syntax is:

msiexec.exe /command line option argument

Where argument might be the path and name of a file.
If a command-line option requires an argument, the argument must follow directly after the option, separated by at least one space. Command-line options are not case sensitive.
Some common command-line options follow:
/I installs an application
/QB sets the level of user interface to basic
/L enables logging
To run a normal installation, use the /I switch to msiexec.exe as in the following.
Msiexec /I sampleapp.msi

If the msi database is not in the current directory for your command prompt, you must specify the full path to the msi file, surrounding the path with quotation marks if it contains any spaces
msiexec.exe /i file://server%201234/share/setup.msi

to run an installation silently add the switch /qn or /qb to the command line

msiexec.exe /i \\server\share\setup.msi /qb
msiexec.exe /i \\server\share\setup.msi /qn

to uninstall an application, you can use the /x switch

msiexec.exe /x file://server/share/setup.msi
or
msiexec /x {Product Code}

to uninstall an application silently

msiexec /x file://server/share/setup.msi /qb

to advertise a product use the /j switch

/jm switch advertises the product of all users of a system and

/ju switch advertises the product for only the current user.

Applying a transform to an MSI package

msiexec /i sample.msi TRANSFORMS=Sample.mst

msiexec /i “\\servername\sample.msi” TRANSFORMS=”\\servername\Sample.mst”

The following example illustrates enabling verbose logging during an installation without user interface. The log file is called "program.log" and is placed in the TEMP directory.
msiexec /qn /l*v “c:\windows\temp\program.log” /i \\server\share\setup.msi