Summary: How to detect different modes of installation.When building an application installer, it's often necessary to distinguish between different modes of installation, i.e. initial installation, repair, upgrade, uninstall, etc. And as with everything important in MSI, detecting the mode of installation is a PITA (and by PITA, I do not mean flat bread of Mediterranean origin). To help you a little bit, here is a table adopted from a StackOverflow topic (and comments), that shows the values of various Windows Installer properties can help you determine the installation mode:
You can use logical operators NOT, AND, OR to build complex conditions.
Here is how you can detect some common conditions:
- NOT Installed
- NOT Installed AND NOT PATCH
- NOT REMOVE
- NOT Installed OR MaintenanceMode="Modify"
- Installed AND UPGRADINGPRODUCTCODE
- Installed AND NOT REMOVE
- (REMOVE="ALL") AND (NOT UPGRADINGPRODUCTCODE)
MSI Property Patterns: Upgrading, FirstInstall and Maintenance
Upgrading, FreshInstall, Maintenance and other MSI convenience properties
MSI Writing Guidelines: Installation Scenarios
How to execute custom action only in install (not uninstall)