Upgrade Codes | Uninstall and upgrade with a new MSI

How do I get Windows Installer to automatically uninstall an existing installed application and install my new MSI using the MSI Upgrade Code table?

Let’s start with a Scenario

Say you have a new revision of your product and have already updated the necessary contents within the MSI package itself. You also need to deploy your new package across multiple workstations and ideally, would like to do this silently without any client nor administrative involvement whatsoever.

Disclaimer Alert! For this example, I will be using the Shark007 Advanced Codecs MSI purely for demonstration purposes, I do not own any rights nor am I associated with Shark007.

If you would like to check out the Shark007 Codec, I highly recommend you do so below. Shark007 is a free application containing a suite of many great video and audio codecs including an advanced user interface tool.

https://shark007.net

Anyway, moving on to the demonstration!

Start by opening your MSI in InstallShield, Orca, InStedIt or whatever tool you use when editing an MSI. So long as, you can access the necessary MSI Tables.

In my case and within this example, I need to upgrade my client workstations to version 11.3.0.

For the record, it is not wise to directly edit a vendor’s MSI. If you need to make changes to the install to accommodate your organisational procedures, you should be using a Transform “.mst”. However, let’s pretend for now that I am updating an MSI that was compiled by myself, internally for my organisation, just for this example.

The following are key variables I want you to keep in mind for this demonstration.

  1. Product Version
  2. Product Code
  3. Upgrade Code
  4. Package Code
Displaying Product Code and Package Code of InstallShield General Information
InstallShield General Information

Let’s change our Product Version. For this scenario, let’s say there has been a multitude of changes since 11.2.1 so that warrant’s a significantly newer version. However, the update is only minor.

There are no standard’s as far as I am aware, in relation to what you’d consider Major, Minor or a Build. So, Im going to leave that for you to decide or research if you wish. In any case, I’ll be incrementing the minor octet of the Product Version to 11.3.0

Keep in mind this is for demonstration purposes and at writing of this article there may or may not be a version 11.3.0 of Shark007.

Displaying Product Version of InstallShield General Information
Product Version

You’ll need to generate two new GUID codes.

  1. Product Code
  2. Package Code

Do not change your Upgrade Code, this never changes and you will understand why later.

The Product Code is a unique identifier for your MSI Package.

Windows Installer also requires that you generate a new Package Code if the contents within your MSI have changed. Go-ahead and generate a new Package Code and Product Code by pressing the {…} button. This will automatically generate a new unique code for you.

InstallShield Codes to be Generated for new MSI
Codes to generate
Package Code Generation InstallShield Recommendation
Enlarged fine-print

Grab a copy of your Upgrade Code from the General Information window.

Displaying the Upgrade Code of the new MSI
New MSI Upgrade Code must be the same!

Browse down to Direct Editor within InstallShield at the bottom of the Installation Designer tab to find your Upgrade Table. Or simply select your Upgrade Table if you’re using Orca, InStedIt etc.

Displaying the Direct Editor of InstallShield to access the Upgrade Table of the MSI
Accessing the MSI Upgrade Table

Once you have found your Upgrade Table, create a new entry and enter the following values. These apply to our old product.

UpgradeCode: You can guess what goes here, paste your Upgrade Code here! This means, for any MSI product already installed and found on the native Windows system with this Upgrade Code, this entry within the Upgrade Table applies.

VersionMin/Max: Any version found to be installed between (in my case) 0.0.1 – 11.2.9. I say, “In my case” because I want any older installation between and including 0.0.1 – 11.2.9 to be uninstalled for my new version 11.3.0 to replace it.

Attributes: Set this to 257

ActionProperty: The property that is set when the following ruling applies. Basically, what Windows Installer is told to do when this entry applies.

Upgrade Code Table Entry for InstallShield
What to do with Old Product Versions

Now let’s repeat the same, but for our new product.

UpgradeCode: Again, “The Code that never changes”.

VersionMin: The minimum version of the contents within this new package, essentially the version to be installed.

Attributes: Set this to 2

ActionProperty: The property that is set when the following ruling applies. Basically, what Windows Installer is told to do when this entry applies.

Displaying InstallShield Upgrade Code New Product Version Entry
What to do for New Product Version

Before continuing, here is a snapshot of the General Information window of the old version and the new version. So up to this point, we should have two different Product Versions, Product Codes and Package Codes but our Upgrade Code is still the same.

Previous

Displaying the General Information of Old MSI
General Information of Old MSI

New

Displaying the General Information of New MSI
General Information of New MSI

To summaries what we have completed so far.

  1. We have a new release that is version 11.3.0, so we have updated the Product Version value.
  2. Generated a new Product Code
  3. Generated a new Package Code
  4. Updated the Upgrade Table by creating two entries.
    • What to do when versions 0.0.1 to 11.2.9 are found to be installed already
    • The minimum version that needs to be installed i.e. our new MSI product.
Displaying this Examples Upgrade Code Table of InstallShield
Upgrade Code Table

Let’s now go ahead and test out our new product install. I have already run up a Windows 10 Virtual Machine and installed version 11.2.1 as you can see in Add and Remove Programs. Note the version installed is 11.2.1.

Displaying Windows Add and Remove Programs Window
Add and Remove Programs – Old Installation

Copy your MSI Installers (old and new) to your Test Machine. Install the old/current MSI first, wait for that to complete and then run your new MSI installer.

Displaying the old and new MSI

Old / New

While installing, your new MSI should begin by removing the previous contents of any older version found to already be installed in Windows. For this example, this will be any version between 0.0.1 – 11.2.9.

During my test, Windows Installer obviously found 11.2.1 installed and is removing it.

Screenshot of Windows Installer removing old version.
New MSI – Uninstalling old version

After removing the contents of 11.2.1 Windows Installer is now completing the installation of the new MSI Package 11.3.0 by copying the new contents over.

Screenshot of Windows Installer Installing new version.
New MSI – Installing new version

Finally, we have a successful completion!

Displaying Windows Add and Remove Programs Window
New MSI Installation Complete

Sure enough! Add and Remove Programs is reporting that 11.3.0 has been successfully installed and 11.2.1 has been removed.

Hurrah!

Add and Remove Programs displaying newly installed MSI version.
Add and Remove Programs – New Installation

Facebook Comments

About: Dale


%d bloggers like this: