Thursday, November 10, 2011

Handling Installtion and uninstallation of files in Windows Installer MSI

  1. As the windows installer technology is design in such a way it take cares of the important application phases such as installation,uninstallation and repair without worrying much.But in this post i would like to throw some light on windows installer file versioning rules and how you can have a fine grained control on those files used by the application using some methods,tweaks and properties.
  2. The windows installer operates on files using certain attributes such as Version,Date and Language.
Window Installer file Overwrite Rules :

1)If both files have version attributes, the file with the higher version will be installed.
2)if the two files have equal versions, Windows Installer does not check the file dates.
3)If one file has a version attribute and the other does not, the versioned file will be installed.
4)If neither file has a version, if the file on the system has identical creation and modification dates, the file in the installer will overwrite it. Otherwise, the file is assumed to contain user data and settings, and will not be overwritten. If the Create date is later than the Modified date, the file is considered unmodified, install the
5)If the file being installed has a different language than the file on the computer, favor the file with the language that matches the product (product language) being installed.Language-neutral files are treated as just another language so the product being installed is favored again.
Methods for Files Modifaction during installation and uninsatllation of application phase:

Using Public property REINSTALLMODE with switches avilable
Using the Permanent Component attribute
Using the NeverOverwrite Component attribute setting
Using Companion file Concept
Using the RemoveFile table
Using Public property REINSTALLMODE with switches avilable
  • The REINSTALLMODE property contains a string made of a collection of letters indicating how files should be overwritten.It is used in conjunction with the REINSTALL property. The default value is “omus” (order-independent), where o indicates that older files should be overwritten with new files, m and u indicate that machine and user registry data should be reinstalled, and s indicates that shortcuts should be reinstalled.
  • To modify file-overwrite behavior, you can replace the o in the REINSTALLMODE value with another letter indicating the desired behavior. Some of the possible values are e, to overwrite a file with an older or equal version, or a, to overwrite existing files without checking their version information.
  • Example :  msiexec /i app.msi REINSTALLMODE=amus REINSTALL=ALL
Using the Permanent Component attribute
  • when a MSI uninstallation takes place all the resources installed during the installed phase will be removed from the system.But there are cases when a corresponding file needs to be remained on the system after the uninstallation.The solution to this approach is to set the permanent attribute of the component to 16 .  
Using the NeverOverwrite Component attribute setting
  • If  the Never Overwrite component attribute is set (value:128), Windows Installer will skip installing the component if its key file is already present on the target system. If the component’s key file is not present on the target system, Windows Installer will follow the normal file-overwrite behavior.
Using Companion file Concept
  • Companion file means the file whose installation logic depends on the versioning of its companion parent.
For example,
File     |   Version
B             A
  • In the above case the installation state of File B depends upon the file versioning rules and the versioning information for File A.
Using the RemoveFile table
  • The MSI removes the files which are installed by it.but there are some files which are created after the launch of the application which are left behind after the uninstalltion.To overcome this a correponding entry in the RemoveFile table can be made.
Out of the above methods described the RemoveFile table and Permanet attribute setting are normally used during uninstallation.

No comments: