Tuesday 2 June 2020

How to use MSI Public Property: Transform vs Command Line

What is a MSI property?


MSI properties are global variables used by Windows Installer during the installation. The value of these variables can be used by the Windows Installer to configure the software installation.
The MSI properties are of three types:
  1. Private Properties - Must be included within the installer database.
  2. Public Properties -  Can be included in the installer database, in transform, passed as command line or through the dialog boxes during UI install. 
  3. Restricted Public Properties

Passing MSI Public Property via Transform vs. Command Line


Since a public property can either be included in the transform (the MST) or it can be passed in the command line, there is a difference how windows installer treats it in both the cases.
A public property when included within the MSI or MST enables Windows Installer to use the same property value during the MSI repair. However, if the MSI was installed by passing the public property in the command line, its value is skipped during the repair. 

Cause:

When a MST is used for installation, Windows Installer will retain a cached copy of the transform in C:\Windows\Installer folder and its path is saved HKCR\Installer\Products\ registry.
During the repair ( which could be triggered by self-heal, active setup or through ARP), Windows Installer will automatically use this cached transform and the property values included in the MST will be used.
On the other hand, if the property was passed in command line during installation, Windows Installer will not keep a track of it and will either ignore the property or will use the default value of property present in the MSI/MST.

Limitations of using public property in command line:

Many times, the property values are internally used to define the application settings either in form of registries or is saved in app's configuration files. When this application is repaired, it should retain same configurations that were defined by the admin during the fresh install.

Let us assume a MSI which has a property “AUTOUPDATE=YES”, we modified the property via command line to “AUTOUPDATE=NO”.
Now, when this MSI is repaired, Windows installer will use the property value from MSI and our update settings will be reset to default i.e. “AUTOUPDATE=YES”, thus hampering the application functionality.

Let us understand with the help of an example:

Suppose we have a MSI “Test_Properties.msi which is transformed by “Test_Properties.mst” and the MST contains a public property “PROPERTYTOBECHECKED=INSIDEMST”.

Case 1 - Fresh Installation

In this case, when MSI+MST are installed, the property included in the MST will be used. It can be verified in the LOG file as well.
When repair is triggered, log file will show same property value.


Case 2 – Fresh Installation where MST and command line have different property value.

Here, MST has “PROPERTYTOBECHECKED=INSIDEMST” while the property value passed in command line is “PROPERTYTOBECHECKED=OUTSIDEMST”.
LOG file clearly shows the value in MST being overwritten by the value passed in command line.



In this case, when we trigger the MSI repair, let's say using “/F” parameter, Windows Installer will use the property value included in the MST which was cached in the C:\Windows\Installer location.


Overview: