PDA

View Full Version : How to Prevent Installation of Older Versions (Basic MSI)



grantmi
06-27-2007, 10:08 AM
We use Major Upgrades to upgrade the Product on the PC, which is find if the user is trying to install a later version than is already on the PC.

However, if the user tries to install an older version of of our Product on the PC (ie. there is already a later version installed on the PC) we want to prevent to installation of the older version continueing.

Step 1: Detect that a later version is installed on the PC.
In Media > Upgrades - Create a new Major Upgrade Item.
- Call it PreventInstallOfOlderVersions
- On the Common Tab:
- Set Products sharing my upgrade code.
- Set Within a specific range of versions.
- On the Advanced Tab:
- Upgrade Code should match your upgrade code GUID.
If you have Installshield 2008:
- Set Minimum Version = ***ALL_VERSIONS***
If you have a previous version of Installshield:
you will need to hardcode the Product Version eg.
- Set Minimum Version = 1.0.0
Note: Setting Minimum Version = [ProductVersion] doesn't work
- Set Include Minimum Version = No
- Leave Maximum Version Blank
- Set Include Maximum Version = No
- Leave Language blank
- Set Exclude Specified Languages = No
- In Additional Settings
- Set Detect Only = Yes
- Set Detect Property = NEWER_VERSION_ALREADY_INSTALLED

Step 2: Setup an Install Condition (Launch Condition) to only allow the Installation to continue if the property NEWER_VERSION_ALREADY_INSTALLED is not set.
In General Information - Project Properties create/Add and Install Condition:
- Condition = NOT NEWER_VERSION_ALREADY_INSTALLED
- Message = A newer version of [ProductName] is already installed.

Step 3: Make sure the FindRelatedProducts action appears before the LaunchConditions action, otherwise the NEWER_VERSION_ALREADY_INSTALLED property will never be set when the LaunchConditions (Install Conditions) run.
In Behaviour and Loagic - Sequences. In the Installation - User Interface sequence move FindRelatedProducts above LauchConditions (by right clicking on FindRelatedProducts and choosing Move Up or by Manually changing its Sequence Number).

Now test your install by building a version lower than one that already exists. Try install it and you should get a message box telling you that a New Version is already installed and the install should quit.

RobertDickau
06-27-2007, 11:10 AM
Thank you for posting the detailed instructions. Some good news is, with InstallShield 2008, new MSI projects automatically get this functionality, using a detect-only major upgrade item to detect an older version being installed, along with an error-then-exit custom action that runs if a downgrade attempt is detected.

grantmi
06-28-2007, 02:48 AM
Thanks for the reply Robert.

I attended the Installshield 2008 Customer Lab in the UK a few weeks back. I don't remember that being mentioned but that would be a good addition to a new default project.

As a slight asside, in the Max Version field of the Majour upgrade table Installshield now puts ***ALL_VERSIONS***. This puts the ProductVersion into the Upgrade table at build time. (However, ***ALL_VERSIONS*** does not work in the Minimum Version field, ***ALL_VERSIONS*** gets put in the msi rather than the product version.)

Seeing that you can use [ProductVersion] in the Minimum Version field I was wondering why they didn't use this for Maximum Version (instead of ***ALL_VERSIONS***)


Editing Note: Since writing this post I have found out that using [ProductVersion] in the Minimum and Maximum version fields does not work. Which explains why Macrovision went to the trouble of creating the ***ALL_VERSIONS*** flag.

bryanwolf
06-28-2007, 08:18 AM
The ***ALL_VERSIONS*** issue in the minimum version only applies to previous versions of InstallShield.

grantmi
06-28-2007, 10:16 AM
OK, I have to confess I am still using IS12, I assumed IS2008 would be the same.

bryanwolf
06-28-2007, 10:20 AM
This is something we addressed in future versions to provide the functionality you are specifically asking about :)

While you're going to want to implement it manually in IS12, IS2008 will do this for you automatically (and it updates based on version changes and what-not).