kmcnaught09
Posts: 3
Joined: Thu Jun 25, 2020 5:02 pm

Uninstall works from inside AI, but not when run externally

I'm building an installer for a product that previously used an installer created by a Visual Studio Setup Project. I've made a brand new AI installer for a new major upgrade v2.1.0. The installer itself is working, but I'm struggling to get the correct upgrade behaviour when the previous version (v1.1.12) of my app is installed.

What I've tried:

Attempt 1
- Setting the UpgradeCode the same as the old installer's UpgradeCode in "Product Details"
- Setting a brand new ProductCode

Attempt 2
- Setting a brand new main UpgradeCode in "Product Details", but adding the old installer's UpgradeCode in "Upgrades"
- Setting a brand new ProductCode

In both these cases, the new app gets installed alongside the old app and uninstallation does not occur.

Attempt 3
- Setting the UpgradeCode the same as the old installer's UpgradeCode in "Product Details"
- Setting the ProductCode the same as the old installer's ProductCode in "Product Details"

Attempt 4
- Setting a brand new main UpgradeCode in "Product Details", but adding the old installer's UpgradeCode in "Upgrades"
- Setting the ProductCode the same as the old installer's UpgradeCode in "Product Details"

In both these cases, if I run the new installer from within AdvancedInstaller, the previous version gets uninstalled before the installer begins, leading me to believe it was correct behaviour! However, when I now run the build .exe from the SetupFiles directory directly, I get the error "Another version of this product is already installed.". I do not understand why the behaviour is different. I've also tried running the .exe as Administrator in case there was a difference in permissions, but this gives the same error.

From my understanding of ProductCodes, "Attempts 1/2" should be the correct approach, since different versions of the same app are identified by UpgradeCode and should have different ProductCodes. However, I've not been able to get this working at all. Is there something special I need to do to deal with the case where the previous version of the app was installed with a different installer?

Any pointers much appreciated!
Catalin
Posts: 6598
Joined: Wed Jun 13, 2018 7:49 am

Re: Uninstall works from inside AI, but not when run externally

Hello and welcome to Advanced Installer forums,

Normally, to achieve what you want, the first attempt is what should be done. Please allow me to explain why:

The UpgradeCode is a GUID representing a related set of products. A set of different versions of your application will have the same UpgradeCode. This enables newer versions of your application to search and upgrade previous versions installed on the same computer.

Basically, in order for your new version to be able to detect an older version, the two versions must have the same UpgradeCode.

The ProductCode property is a unique GUID used to identify your application. This identifier varies from version to version of the same installer.

Since the ProductCode is used to identify an application, it means that two applications having the same ProductCode can not be installed on the same machine. When trying to do so, the following message will appear:
Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Programs and Features in the Control Panel.
So, the steps should be as it follows:

- in your Advanced Installer project, set the UpgradeCode to the UpgradeCode of the already installed application ("Product Details" page --> "Product IDs" tab)

- increase the version - e.g. if version 1.0.0 is installed, the version in your Advanced Installer project should be higher (e.g. 1.0.1; 2.0.0; etc.). This can be done from the "Product Details" page --> "Product Details" tab

- make sure that the two ProductCodes (from the already installed version and from the version you build using Advanced Installer) are different
In both these cases, if I run the new installer from within AdvancedInstaller, the previous version gets uninstalled before the installer begins, leading me to believe it was correct behaviour!
This is a custom behavior implemented by us in Advanced Installer. When pressing "Run" (or F5) in Advanced Installer, it automatically uninstalls another version (if one is found).
From my understanding of ProductCodes, "Attempts 1/2" should be the correct approach, since different versions of the same app are identified by UpgradeCode and should have different ProductCodes.
Indeed, the first attempt is the correct one. The second attempt is mostly used if you want your application to upgrade (uninstall) another application. For instance, if you want your setup to uninstall another setup during its installation.

Since it looks like you have done everything correctly, in order for me to further investigate this, could you please forward me the following resources:

- a copy of your .AIP file

- a download link for the setup resulted when building your .AIP file

- a download link for the setup of the "older" version (the one created with Visual Studio)

by e-mail at support at advancedinstaller dot com?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kmcnaught09
Posts: 3
Joined: Thu Jun 25, 2020 5:02 pm

Re: Uninstall works from inside AI, but not when run externally

Hi Catalin,

Thanks for your response.

Having investigated further, it turns out the default on the previous installer was "per-user" and the new installer is "per-machine". Attempt 1/2 are successful (only) if the previous version was installed "per-machine".

This is my final setup, which works:
- Setting the UpgradeCode the same as the old installer's UpgradeCode in "Product Details"
- Setting a brand new ProductCode
- Add the Custom Action "UninstallPreviousVersions" before "Paths Resolution" in the sequence.

The one remaining downside is that the uninstall happens before the user has confirmed the installation. If they cancel the new installer, they will be left with neither app installed. Is there any way around this? It doesn't seem like it's possible to set the "UninstallPreviousVersions" action to be deferred, and if I put it later in the sequence (at the start of Install Execution stage, for instance) the previous app does not get uninstalled.
Catalin
Posts: 6598
Joined: Wed Jun 13, 2018 7:49 am

Re: Uninstall works from inside AI, but not when run externally

Hello,

Thank you for your followup on this.

Indeed, as it is explained in the "Install Parameters" article ("Installation Type" section):
A per-user installation cannot upgrade a per-machine installation, and a per-machine installation cannot upgrade a per-user installation.
A solution to this could indeed be the one presented by you, the "Uninstall Previous Versions" custom action.

As it is stated in the article (linked above):
It is recommended to schedule this custom action before "Wizard Dialogs Stage" -> "Paths Resolution". This way it will run right before the installation starts.
The reason for this is the Windows Installer limitation regarding more install / uninstall processes happening at the same time.

Unfortunately, it is not possible to install another product while one is already installing. The same goes with uninstalling another product while one is already installing (this would be our case here).

With that being said, the uninstall needs to happen during the "Wizard Dialogs Stage", so the limitation will be avoided.

However, there is another way of doing this. You can try to use the "Preserve Install Type of the old version" predefined custom action.
This predefined custom action allows your package to use the same installation type as the version it upgrades through the automated upgrade feature. For example, your package will be installed per-user if it upgrades a per-user installation or it will be installed per-machine if it upgrades a per-machine installation.
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”