install4j

Install4j - How to uninstall previous version and continue with a fresh installation


I am working on a stepping stone version where I am reworking the installer. I need to to use the same application ID but the update does not work between the old and new versions.

Is there a way to uninstall the previous version and then start a fresh install?

I was able to do this with different Application IDs, where I detected the old version by using ApplicationRegistry.getApplicationInfoById(APPLICATION_ID) and checking the version. Then calling the Execute previous uninstaller on the directory where the old version is installed.

But when the Application ID is shared the installer thinks it is in update mode. Then even if I call Execute previous uninstaller there are files left over from the previous version that are normally kept during updates, but that I want to get rid off in this scenario.

Is there a way to achieve this? Can I do a full uninstall and tell the installer to continue as a new installation(Ideally without restarting the installer so the user does not get prompted twice for admin access)?


Solution

  • You could use a "Run executable" action to execute the uninstaller. To provide feedback you should call a "Set the progress bar" action with the "Type of change" property set to "Set indeterminate state".

    After that, to ensure that the installer does not think it's in upgrade mode anymore, add a "Run script" action and call

    File dir = context.getInstallationDirectory();
    context.setInstallationDirectory(new File(dir, "dummy"));
    context.setInstallationDirectory(dir);
    return true;
    

    I've added this to our issue tracker, it should be a property on the "Execute previous uninstaller" action.