I'm using Wix to code my own MSI installer. I need to run the custom action only before uninstallation of the product, but before any registry values or files are removed. I did the following (just to try):
<Property Id='CALC'>Calc.exe</Property>
<CustomAction Id='BeforeUninstall01' Property='CALC' ExeCommand='' Return='check' />
<InstallExecuteSequence>
<Custom Action='BeforeUninstall01' After='InstallInitialize'>Installed</Custom>
</InstallExecuteSequence>
It works if I choose to uninstall
from the Control Panel, but if I run my MSI instead (while it's already installed) the BeforeUninstall01
custom action is triggered anyway, which it shouldn't.
Any idea how to change this condition?
try an additional condition to check that the product is not being upgraded
You choose the condition "Installed".
Given your code the wanted condition using the built-in property "REMOVE" will result in:
This also allows you (even if it is not necessary) to uninstall a single feature, but not the whole product without that your custom action (ca) is triggered. In other words, the ca is triggered always and only, if
Yours condition starts the ca always, but not for first install (incl. repair, update, uninstall, modify, patch, etc. This is not, what you need, indeed.
The condition of Reubz is slightly different, this would start always but not for first install and not during a Major Upgrade, which is not a real improvement here.
Concerning sequencing: If your ca really needs elevated rights then you have to run the custom action "deferred" with system rights and change your given ca definition to (if not, let it):
(I am not a WiX wizard, only I know MSI quite well, so I have not checked any part of your WiX code, only the issues.)