Issue
We are currently using a different randomly generated Application ID & installation directory for each new product version released. For example:
- Version 10 would have application ID 12345 & directory of "ProductName10"
- Version 11 has an application ID of 98765 & directory of "ProductName11"
We chose to use separate IDs & installation directories for each new version to allow users to demo the new version without having to remove the previous version. If we used the same ID it would overwrite the previous version and invalidate their license.
However, for users that know they want to upgrade it is a 2 step process for them to install the new version and then find & run the uninstaller for the previous version. What we would like is to prompt the user with an option to uninstall the previous version (if found) during the installation process.
We have looked for some prebuilt option in the Install4j settings to allow this but have not found a good solution. Basically our desired workflow is as follows:
- Display the first standard welcome screen
- User selects our custom options and begins installation
- During installation: FIRST check if previous versions exist (using known Application IDs or other method), if so display message to user with confirmation to remove previous version
- If user selects “Yes” run uninstaller for previous program BEFORE completing the installation for the current new program.
Ultimately I have 2 questions related to this:
- What is the best way for us to accomplish our desired workflow?
- If there is no easy way, is there another way to setup our application versions so that we can have a similar process to allow us to have separate application versions and somehow auto uninstall the previous version?
NOTE: Our solution needs to also be cross compatible with Windows, Mac, & Linux
Thanks!
Solution
There is an "Execute previous uninstaller" action that can uninstall from any directory if the "Installation directory" property is set and the "Only if the same application ID is found" property is deselected.
To find out where previous versions with different application IDs are installed, use
ApplicationRegistry.ApplicationInfo[] applicationInfos =
ApplicationRegistry.getApplicationInfoById("<application ID of previous version>");
if (applicationInfos.length > 0) {
context.setVariable("uninstallDir",
applicationInfos[0].getInstallationDirectory().getPath());
}
in a "Run script" action. Then you can set the "Installation directory" property of the "Execute previous uninstaller" action to
${installer:uninstallDir}
and its "Condition expression" to
context.getVariable("uninstallDir") != null
Answered By - Ingo Kegel
Answer Checked By - Mildred Charles (JavaFixing Admin)