MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: MDAC not too old?[Next]: Windows 2000 or Greater?
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->Launch Conditions->Prevent Downgrades of Your Product

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.


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: MDAC not too old?[Next]: Windows 2000 or Greater?


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.