1
votes

We changed our Application from 32-bit to 64-bit with the last version increase but now our installer doesn't recognize when there is a previous version installed, so it doesn't unistall the previous version when installing the new one.

Example: App version 1.0.0 32-bit App version 2.0.0 32-bit App version 3.0.0 64-bit

App version 1.0.0 is installed and version 2.0.0 installer is executed -> App version 1.0.0 gets uninstalled and version 2.0.0 installed.

App version 2.0.0 is installed and version 3.0.0 installer is executed -> App version 2.0.0 is not touched and version 3.0.0 gets installed.

We didn't change the Application id.

Version 2.0.0 Setup was generated with Install4j 6.1.6 and Version 3.0.0 gets generated with 7.0.10

1
Thanks for your edit to fix my answer, others have rejected it, but I have now applied it. Checking infos for null is not necessary, because the returned array is empty if there are no matching installations. - Ingo Kegel

1 Answers

1
votes

The previous version is stored in the registry and as of install4j 8.0 the 64-bit installer does not check the 32-bit registry for previous installations to prevent a 64-bit installation ending up in the 32-bit program files directory.

To uninstall the 32-bit installation, add a "Set a variable" action to the "Startup" node of the installer, with the variable name "previousDir" and the script

if (!context.isUpdateInstallation()) {
    ApplicationRegistry.ApplicationInfo[] infos = 
        ApplicationRegistry.getApplicationInfoById(context.getApplicationId());
    if (infos.length > 0) {
        return infos[0].getInstallationDirectory().getPath();
    }
}
return null;

Then add an "Execute previous uninstaller" action to the "Installation" screen before the "Install files" action with the "Installation directory" property set to

${installer:previousDir}

and a condition expression of

context.getVariable("previousDir") != null