Uninstall another product after new product installation - Advanced Installer Community
Mahesh
Posts: 12
Joined: Tue May 22, 2012 11:24 pm

Uninstall another product after new product installation

Hi,

I have product A and product B. Both are two unrelated products but have similar functionality.

I want to uninstall product A only after successful installation of product B. So, I sequenced the uninstallation of product A in the InstallExecuteSequence of product B giving -1. But I get error -

Action ended 10:55:07: InstallFinalize. Return value 1.
MSI (s) (78:50) [10:55:07:545]: Doing action: UninstallOldProduct
Action 10:55:07: UninstallOldProduct.
Action start 10:55:07: UninstallOldProduct.
MSI (s) (78:50) [10:55:07:545]: Note: 1: 2762
Error 2762. Cannot write script record. Transaction not started.
MSI (s) (78:50) [10:56:11:476]: Product: XYZ Module -- Error 2762. Cannot write script record. Transaction not started.

Action ended 10:56:11: UninstallOldProduct. Return value 3.


I tried sequencing the uninstall process after InstallExecute but before InstallFinalize. I still got the same error. How is this usually done according to my needs ?


Thanks,
Mahesh.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Uninstall another product after new product installation

Hi Mahesh,

Providing product A is MSI based, try adding its upgrade code to product B's project -> Upgrades page -> Upgrades section instead.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Mahesh
Posts: 12
Joined: Tue May 22, 2012 11:24 pm

Re: Uninstall another product after new product installation

Hi Mihai,

Thanks for the reply. I tried that initially. But that will first uninstall product A and then installs product B. But my requirement is uninstall of product A only after successful installation of product B.

My Solution:

I have created a custom action with the execution property "Asynchronous Execution, do not wait for return". And in the custom action, I am calling MsiEnumRelatedProducts to check if product B is successfully installed. If yes, then I ago ahead uninstall the product A using MsiConfigureProductEx. It is working.

I have few other questions:

1. Is there any other way to check if product B is successfully installed ? Like checking return code for the product B operation before launching the custom action.
2. Will custom actions scheduled with property ""Asynchronous Execution, do not wait for return" will still be processed if the windows installer failed of previous operations ?


Thanks,
Mahesh.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Uninstall another product after new product installation

Hi Mahesh,

Not sure on the later ramifications of your settings but just FYI another predefined way you can try is to enable "Install new version first and then uninstall old version" option and keep the Upgrades page approach. This method also has some delicate drawbacks described in the linked article.
Is there any other way to check if product B is successfully installed ? Like checking return code for the product B operation before launching the custom action.
MSI based installers have a key named with the Product Code in the following registry locations:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
Will custom actions scheduled with property "Asynchronous Execution, do not wait for return" will still be processed if the windows installer failed of previous operations ?
That option means that the current stage (Wizard Dialogs Stage or Install Execution Stage) will wait for the custom action return code after all actions have been executed. The actual return code is ignored by the installation.
What exactly do you mean by this, can you be more specific please?

Also, another related predefined custom action you can look into is Uninstall previous versions.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Mahesh
Posts: 12
Joined: Tue May 22, 2012 11:24 pm

Re: Uninstall another product after new product installation

Mihai,

Thanks for the detailed reply.
Will custom actions scheduled with property "Asynchronous Execution, do not wait for return" will still be processed if the windows installer failed of previous operations ?
By above I meant, I have a custom action which is supposed to run (Asynchornous Execution) at the end of current process. If current process fails for any reason, will the custom action still be executed ? And is there a way that process fail return code can be used for custom action launch condition ?


Thanks,
Mahesh.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Uninstall another product after new product installation

Hi Mahesh,

A custom action execution is entirely dictated by its "Execution Condition". If the condition is evaluated to true, the custom action will be executed. Another scenario is if the installation sequence is interrupted(user or failed action) until your custom action executes. In this case the whole installation will be rolled back and your custom action not executed of course.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”