Launch Condition: Prevent Downgrades of Your Product |
I normally treat upgrades (installing a newer version of an installed product) the same as downgrades (replacing with an older version), however some people don't want to allow this and at times there will be a good reason to prevent it.
The following code (based on code posted by Konstantin Malakhanov) will search for a newer version of your product and if so display an error message:
#define? MSG_NEWER_PRODUCT_INSTALLED The same or higher version of <$ProdInfo.ProductName> is already installed! Please uninstall this product first. #( ;--- Look for any newer already installed version of this product ------- <$ProductFind UpgradeCode="<$ProdInfo.Guid.UpgradeCode>" ;;Must define in ".ver" file! VersionMin="<$ProductVersion>" ;;Look for more recent versions than this one Property="NEWER_PRODUCT_INSTALLED" ;;Define this property if we find a newer product. Inclusive="N" ;;Don't actually want to fail if same version (want maintenance dialogs) Message="" ;;Don't abort if not found! > #) #( ;--- Test for non-existance of property (INSTALL time only) ---------- <$AbortIf Condition=^NEWER_PRODUCT_INSTALLED and (<$CONDITION_INSTALL_ONLY>)^ Message=^<$MSG_NEWER_PRODUCT_INSTALLED>^ Seq="FindRelatedProducts-" ;;Must validate after product detection above! SeqTable="InstallExecuteSequence InstallUISequence" > #)
The newer version must be manually uninstalled before the install of the older product can proceed.