larryjiang
Posts: 5
Joined: Fri Sep 06, 2013 12:43 am

How to run a SQL script file during patch removal

Hi,

I'm using advanced Installer 10.3 enterprise version to build a target msi installer, a update msi then a msp. I need to execute a SQL script during patch installation and another SQl script during patch uninstall if it takes place. I managed to have the SQL script ran during patch installation. However, I'm not able to make the SQl script executed during patch removal. I need some suggestions to set running flag or conditions correctly. I also try to execute a custom action during patch removal to achieve the same goal but no luck. It seems no action I can set if remove the patch from Windows Add/Remove program.

Here is what I have tried:
SQL Execution: uninstall or rollback
condition: (Installed AND ( REMOVE = "ALL" OR AI_INSTALL_MODE = "Remove" )) OR PATCH

Try to call a custom action function during patch removal:
Execution stage is uninstall and condition is PATCH.

Please advise what condition(s) I have set it wrong and how I debug it?

Thanks in advance.

Larry
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to run a SQL script file during patch removal

Hi Larry and welcome to Advanced Installer forums.

Please keep in mind that the "PATCH" property is set only during the installation of a patch.

If you want to set a condition for the uninstallation of a patch you can try to use the "MsiPatchRemovalList" or "MSIPATCHREMOVE" properties.

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

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
larryjiang
Posts: 5
Joined: Fri Sep 06, 2013 12:43 am

Re: How to run a SQL script file during patch removal

Hi,
Thanks for your quick reply. Here is my scenarios:

Target.aip (an installer to install app)
Update.aip (a patch project based on target.aip)
- this aip has sql script needs to run when the msp was removed from Add/Remove Program
Patch.aip (build msp file based on the msi generated from Target.aip and Update.aip)

My question is how to set the execution flag/condition for the SQL script in Update.aip?

Could you give example of how to set MsiPatchRemovalList or MSIPATCHREMOVE in the aip?

Thanks,

Larry
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: How to run a SQL script file during patch removal

Hi Larry,

In the "Update.aip" project you can try to use the condition that you written in your first post with the only difference that the [PATCH] property will be replaced by the [MSIPATCHREMOVE] property (i.e. (Installed AND ( REMOVE = "ALL" OR AI_INSTALL_MODE = "Remove" )) OR MSIPATCHREMOVE ). However, please keep in mind that the SQL script will be executed during the patch removal only if it was contained by the Target MSI package.

A patch is the result of a diff that is applied between the Target and the Upgraded MSI packages.

When the Target MSI is installed it is cached by Windows Installer in the "C:\Windows\Installer" location. Then, when the patch is installed, it is also cached in the same location, it is concatenated to the cached Target MSI (the Upgraded MSI results) and a repair action is applied.

When a patch is removed the Target MSI package is launched in maintenance mode and its features are reinstalled in order to raise their initial source files.

So, for a custom action or an SQL script to be executed when the patch is removed from the "Installed Updates" list, that custom action must be contained by the Target MSI, otherwise it will not be found when the repair is applied on that MSI during the patch removal. However, all the new files that were added to that patch will be removed because they are not contained by the Target MSI, so it will remove them during the repair.

Hence, in what regards the patch removal feature, we would not recommend to use this feature because of the incomplete support in Windows Installer. For more details you can take a look on the "Uninstall option is not available for patch" thread.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”