netrustPS
Posts: 40
Joined: Tue Dec 20, 2016 4:40 am

Uninstall Old Prerequisite during Prerequisite Installation

My installer v1 has a prerequisite v1 bundled with it. My installer v2 has a prerequisite v2 bundled with it. I need to update the prerequisite to v2 but I am not able to just run the prerequisite for v2 on top of the prerequisite v1 installation as it will trigger a forced reboot since the msi is ran silently, or is totally unable to install because the version gap is too big i.e v1 -> v3 therefore causing the installer itself to fail. This prerequisite is mandatory for my application.

To solve the issue I can trigger a uninstallation of prerequisite v1 before the installation for prerequisite v2 begins. I have consulted the prerequisite settings and I see that I am able to set conditions to decide whether a prerequisite is to be installed, but do not see any options to uninstall old prerequisites or run custom actions at that stage.

Any advice would be helpful. Thank you.
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi,

A solution for you, is to create a BAT file that removed the V1 of your prerequisite and add that BAT file as a prerequisite before the V2 version of your prerequisite. However, please keep in mind that BAT files can be executed only as 'pre-install' prerequisites.

If you want to add it as a 'feature-based' prerequisite, you can create a simple MSI that has the "Register product with Windows Installer" option unchecked in the "Product Details" page and runs the BAT file at the end through a "Launch file" custom action.

Let me know if this helped, otherwise give me more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
netrustPS
Posts: 40
Joined: Tue Dec 20, 2016 4:40 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi Eusebiu,

Sorry for the late reply, I have tried your suggestion and I would need some additional help before the suggested solution will fully work. I am able to add a batch job that starts the uninstallation of my prerequisite V1 before the installation for my prerequisite V2 begins. The batch job (Containing a WMIC command that uninstalls based on the prerequisite name) however needs administrator rights to run properly. Is there a way to require the prerequisite to run in administrator mode or package the bat in a way so that it requests for administrator rights during execution? This section will work as intended if I run the installer itself as the administrator, but this is a luxury I probably wont have on the user's machines.

The prerequisite install conditions allow for conditions to be checked and the prerequisite will be installed if some or all of the conditions are false. However as the condition I need to check for is that my prerequisite V1 is installed, therefore I need this condition to be all true before the uninstallation batch file should run. I could set it as to be always installed and make the batch job check if the prerequisite V1 exists before it runs the uninstallation command but this would result in the user always seeing in the installer that the old prerequisite versions are to be uninstalled whenever they run the installer. Is there a better way to do this?
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi,
Sorry for the late reply, I have tried your suggestion and I would need some additional help before the suggested solution will fully work. I am able to add a batch job that starts the uninstallation of my prerequisite V1 before the installation for my prerequisite V2 begins. The batch job (Containing a WMIC command that uninstalls based on the prerequisite name) however needs administrator rights to run properly. Is there a way to require the prerequisite to run in administrator mode or package the bat in a way so that it requests for administrator rights during execution? This section will work as intended if I run the installer itself as the administrator, but this is a luxury I probably wont have on the user's machines.
I'm afraid that the "Run as administrator" option cannot be set for a prerequisite itself. This can be set for the whole package in the "Install Parameters" page or for a "Launch file" custom action.

In your scenario, you can add the BAT file as a "Launch file" custom action in a simple MSI as I described in my previous post and check the "Run as administrator" option for that custom action.
The prerequisite install conditions allow for conditions to be checked and the prerequisite will be installed if some or all of the conditions are false. However as the condition I need to check for is that my prerequisite V1 is installed, therefore I need this condition to be all true before the uninstallation batch file should run. I could set it as to be always installed and make the batch job check if the prerequisite V1 exists before it runs the uninstallation command but this would result in the user always seeing in the installer that the old prerequisite versions are to be uninstalled whenever they run the installer. Is there a better way to do this?
If you create a simple MSI that launches the BAT file, you can set it to be executed only when V1 is installed (based on a "Product Version (identify by Product Code)" extended search). Then you can set the MSI to be always installed silently as a prerequisite and it will do no change if the "Register product with Windows Installer" option is unchecked for it and the BAT file condition is false.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
netrustPS
Posts: 40
Joined: Tue Dec 20, 2016 4:40 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi Eusebiu,

To clarify, my options are:

1. Set the whole package to be ran in administrator mode in "Install Parameters". This will run the installer only as the administrator or will it apply to my installed application as well?

2. If I create a simple MSI for the batch file and set it as a custom launch file action can the action run before the installation of my prerequisite V2? Where in the sequence do I put the action?

3. If I create a simple MSI for the batch file and set it as a prerequisite
3a. I can set it to search based on the product code and let the MSI run only when the product is found? But doesnt the install condition trigger when some or all of the conditions are false and not when all conditions are true? Please see screen capture below.
Prerequisite Install conditions.PNG
Prerequisite Install conditions.PNG (15.15 KiB) Viewed 10238 times
3b. I can set the MSI to always be installed as a prerequisite and it will do no change if the batch does not find my prerequisite v1 and if it doesnt register with windows installer. However doesnt this mean that my installer wizard will have this prompt because the prerequisite is set to always run whether my prerequisite v1 is installed or not? Please see screen capture below.
Prerequisite Always Install.PNG
Prerequisite Always Install.PNG (23.05 KiB) Viewed 10238 times
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi,
1. Set the whole package to be ran in administrator mode in "Install Parameters". This will run the installer only as the administrator or will it apply to my installed application as well?
This will set only the installer to run as administrator and every process that it starts during the installation. After the installation finished, that option will not affect your application or anything else.
2. If I create a simple MSI for the batch file and set it as a custom launch file action can the action run before the installation of my prerequisite V2? Where in the sequence do I put the action?
If you create a simple MSI it is recommended to put your BAT file as a custom action after the "Add Resources" action group in the sequence. Then you will add the simple MSI package as a prerequisite before the V2 prerequisite and it will uninstall the old version of your prerequisite before installing the new one.
3a. I can set it to search based on the product code and let the MSI run only when the product is found? But doesnt the install condition trigger when some or all of the conditions are false and not when all conditions are true? Please see screen capture below.
Indeed, the prerequisite is installed only when the conditions are false. That is why I suggested to set the "Always install prerequisite" option for it and create a "Product Version (identify by Product Code)" extended search in the simple MSI package and use it as a condition for the BAT file custom action.
3b. I can set the MSI to always be installed as a prerequisite and it will do no change if the batch does not find my prerequisite v1 and if it doesnt register with windows installer. However doesnt this mean that my installer wizard will have this prompt because the prerequisite is set to always run whether my prerequisite v1 is installed or not? Please see screen capture below.
Yes, the simple MSI will always be displayed on that dialog if the "UI level" is set to "Full UI" in the "Pre-install UI" section from the "Dialogs" page.

If you want it to be installed only when the old version is installed (V1), you can create a "Registry key does not exist" or "Registry value does not exist" that searches for a registry entry related only to version V1. So, the simple MSI will be installed only if that registry entry exists on the machine.

In this case, you don't need to set any condition for your BAT file custom action, because it will be executed only when the simple MSI prerequisite will be installed.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
netrustPS
Posts: 40
Joined: Tue Dec 20, 2016 4:40 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi Eusebiu,
If you want it to be installed only when the old version is installed (V1), you can create a "Registry key does not exist" or "Registry value does not exist" that searches for a registry entry related only to version V1. So, the simple MSI will be installed only if that registry entry exists on the machine.
I have noticed that when I use the "Registry value does not exist" option I am unable to detect REG_SZ but I can see REG_DWORD values. Unfortunately the value I want to check is a REG_SZ value. Is this a limitation?

For a workaround I am using "Registry key does not exist" to check if a version of my prerequisite of the software is installed followed by "File Version" where it checks for a higher version than the prerequisite version im expecting to trigger a false result.
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi,

I tested this and I was able to check for REG_SZ values, as well as for REG_DWORD values. Do you use the latest version of Advanced Installer?

If you cannot pick the registry value you need, you can write it manually, then you can use the "Evaluate..." option and if the value is present on the machine, you should get a "FAILURE" result during the evaluation.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
netrustPS
Posts: 40
Joined: Tue Dec 20, 2016 4:40 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi Eusebiu,

I have updated to Version 13.6 Build 75693 and I am still facing this issue. Please see the following screenshots.
AI Prerequisite Condition.PNG
AI Prerequisite Condition.PNG (22.56 KiB) Viewed 10230 times
Registry Value.PNG
Registry Value.PNG (22.77 KiB) Viewed 10230 times
Ai Condition Result.PNG
Ai Condition Result.PNG (50.65 KiB) Viewed 10230 times
So based on the above screenshots, I have the prerequisite installed and I can see it in my registry. But I am not able to see it through AI? And my condition evaluation cannot find the registry value?
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Old Prerequisite during Prerequisite Installation

Can you try to check the "User 64-bit locations when evaluating conditions on a 64-bit machine" option and see if it works?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
netrustPS
Posts: 40
Joined: Tue Dec 20, 2016 4:40 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi Eusebiu,

I was able to evaluate the registry value condition successfully after checking the checkbox. Didnt think to check that as my test machine was a 32 bit machine. After tweaking the conditions to suit my scenario I am able to make the prerequisite uninstallation batch file run only when it is needed, though it shows the action required as "Skipped" if my prerequisite V2 needs to be installed.

Thanks for your help.
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Uninstall Old Prerequisite during Prerequisite Installation

You're welcome. I'm glad you got this working.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sun0555
Posts: 2
Joined: Wed Oct 12, 2016 10:41 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hi Team,

In My Case , for my older versions we have used JRE7 as prerequisites to install my code.
Now we have updated JRE version from JRE7 to JRE11 .
So now in newer installers i need to remove JRE7 and install JRE11 as prerequisites. Is there any way other then bat script ?

Thanks in Advance

Sunil Kumar.
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Uninstall Old Prerequisite during Prerequisite Installation

Hello Sunil and welcome to Advanced Installer forum,

I am afraid I am not aware of any other way of uninstalling your JRE 7 and installed JRE 11 other than through a script file.

Please let me know if there is anything else I could help you with.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”