Hi all, After searching any possible explanation on the internet, and after trying any possible combination of conditions, I got to the conclusion that this is either a bug or a limitation of Wix/MSI, because there is no condition that could distinguish between an uninstall (from add/remove programs) and an update, when REP is after InstallInitialize, eg <RemoveExistingProducts After="InstallInitialize"/>.
I'm not sure if I should report this somewhere or not, but I will post again my sample here, as this sample proves this bug/limitation. In order to distinguish between an uninstall (from control panel) and an update, I used any possible combination of: Installed, REMOVE="ALL", OLDAPPFOUND and UPGRADINGPRODUCTCODE without success. I created a small sample file that shows exactly this problem, pls see below. The problem can be easily duplicated by doing: 1) build the below sample into a project with version 1.0.0 2) build the same sample but with another version 1.0.1 (change the version in CurrentVersion) 3) run version 1.0.0 => the product will be installed 4) In C:\Program Files\MySmallProject add a dummy file: momo.txt (think of it as a log file generated by running the application) 5) run the second version 101, which _updates_ the product => after the update the momo.txt is !!gone!! even though the component which removes the file is having the condition: (REMOVE=ALL) AND (NOT UPGRADINGPRODUCTCODE) which means that the file shouldn't have been removed during an update only during an uninstall. But if in the code instead of: <RemoveExistingProducts After="InstallInitialize"/> you have: <RemoveExistingProducts After="InstallFinalize"/> by doing all the above steps the momo.txt is _not_ deleted during an update, only during a real uninstall (from add/remove programs), which is the _desired_ behavior. So, it seems that when having <RemoveExistingProducts After="InstallInitialize"/> there is no way to distinguish between an uninstall and an update. The code that proves the above described behaviour: <?xml version="1.0" encoding="UTF-8"?> <?define UpgradeCode = "61608F07-C47C-459F-97DD-CD02D104294C"?> <?define CurrentVersion = "1.0.0"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="SmallProject" Language="1033" Version="$(var.CurrentVersion)" Manufacturer="SmallProject" UpgradeCode="$(var.UpgradeCode)"> <Package Id="*" InstallerVersion="200" Compressed="yes" /> <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLLOCATION" Name="MySmallProject"> <Component Id="mytest.txt" Guid="7CED77A9-597B-456A-BEF7-44C094800A06"> <File Id="mytest.txt" Source="mytest.txt" KeyPath="yes" /> </Component> <Component Id="removeFile" Guid="F82061CB-27F9-41F5-B5FE-2EDCA1F1A8F9"> <RemoveFile Id="remove" Name="momo.txt" On="uninstall"/> <Condition>(REMOVE=ALL) AND (NOT UPGRADINGPRODUCTCODE)</Condition> </Component> </Directory> </Directory> </Directory> <Feature Id="ProductFeature" Title="SmallProject" Level="1"> <ComponentRef Id="mytest.txt"/> <ComponentRef Id="removeFile"/> </Feature> <Upgrade Id="$(var.UpgradeCode)"> <UpgradeVersion OnlyDetect="no" Property="OLDAPPFOUND" Minimum="0.0.1" IncludeMinimum="yes" Maximum="$(var.CurrentVersion)" IncludeMaximum="no" /> <UpgradeVersion OnlyDetect="yes" Property="NEWAPPFOUND" Minimum="$(var.CurrentVersion)" IncludeMinimum="no" /> <UpgradeVersion OnlyDetect="yes" Property="SELFFOUND" Minimum="$(var.CurrentVersion)" IncludeMinimum="yes" Maximum="$(var.CurrentVersion)" IncludeMaximum="yes" /> </Upgrade> <CustomAction Id="NewerVersionDetected" Error="2000"/> <CustomAction Id="CurrentVersionDetected" Error="2001"/> <UI> <Error Id="2000">!(loc.Error2000)</Error> </UI> <UI> <Error Id="2001">!(loc.Error2001)</Error> </UI> <InstallExecuteSequence> <FindRelatedProducts Sequence="100" /> <AppSearch After="FindRelatedProducts"/> <LaunchConditions After="AppSearch" /> <Custom Action="NewerVersionDetected" After="AppSearch">NEWAPPFOUND</Custom> <Custom Action="CurrentVersionDetected" After="AppSearch">SELFFOUND</Custom> <RemoveExistingProducts After="InstallInitialize"/> <!--<RemoveExistingProducts After="InstallFinalize"/>--> </InstallExecuteSequence> <!-- Find previous installation directory --> <Property Id="INSTALLDIR"> <RegistrySearch Id="FindInstallLocation" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDAPPFOUND]" Name="InstallLocation" Type="raw" /> </Property> <CustomAction Id="SetARPINSTALLLOCATION" Property="ARPINSTALLLOCATION" Value="[INSTALLDIR]" /> <InstallExecuteSequence> <Custom Action="SetARPINSTALLLOCATION" After="InstallValidate">NOT Installed</Custom> </InstallExecuteSequence> </Product> </Wix> Thank you, MeCoco ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users