Why file get overwritten when KeyPath is set in Wix - wix

The snippet of Files.wxs generated by heat:
<?xml version="1.0" encoding="utf-8"?>
<Wix
xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Directory Id="dirF5D9BDF13CBC346EDDFD6D0959FFB838" Name="config">
<Component Id="cmp0CBEDCE6B62E5666B3362D0EB41267BC" Guid="*">
<File Id="fil73D1987B7864F07C97735D7E40243AB2" KeyPath="yes"
Source="$(var.App.TargetDir)\config\accounts-example.ini" />
</Component>
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Binaries">
<ComponentRef Id="cmp0CBEDCE6B62E5666B3362D0EB41267BC" />
</ComponentGroup>
</Fragment>
</Wix>
Product.wxs:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="xxx" Language="2052" Version="$(var.ProductVersion)" Manufacturer="xxx"
UpgradeCode="425BDA6F-31B8-47AD-88D8-4B2DBE394XXX">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="New Version [ProductName] has been installed。" />
<MediaTemplate EmbedCab="yes" />
<WixVariable Id="WixUILicenseRtf" Value="./License.rtf" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MANUFACTURERFOLDER" Name="!(bind.property.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="!(bind.property.ProductName)" />
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="XXX_Installer" Level="1">
<ComponentGroupRef Id="Binaries" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentRef Id="RegistryEntries" />
</Feature>
<UIRef Id="WixUI_ErrorProgressText" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="E1F61345-CC60-40FE-8FC4-FBE1598F8XXX">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="!(bind.property.ProductName)"
Description="!(bind.property.ProductName)"
Target="[INSTALLFOLDER]XXX_App.exe"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Microsoft\!(bind.property.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop" Guid="BEDF111F-0889-4317-8E67-41425F00CXXX">
<Shortcut Id="ApplicationDesktopShortcut"
Name="!(bind.property.ProductName)"
Description="!(bind.property.ProductName)"
Target="[INSTALLFOLDER]XXX_App.exe"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Microsoft\!(bind.property.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="0D919675-E219-43EA-AAB3-E6F81A013XXX">
<RegistryKey Root="HKCU"
Key="Software\Microsoft\Windows\CurrentVersion\Run">
<RegistryValue Name="!(bind.property.ProductName)"
Type="string"
Value="[INSTALLFOLDER]XXX_App.exe"/>
</RegistryKey>
</Component>
</DirectoryRef>
<UI>
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="启动!(bind.property.ProductName)" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<Property Id="WixShellExecTarget" Value="[INSTALLFOLDER]XXX_App.exe" />
<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
</Product>
</Wix>
Every time I install a new version, it overwrites the existing file accounts-example.ini.
The overwrite behavior is expected for accounts-example.ini, but I will have another file user.db do not want to be overwritten.
It says if KeyPath is set to 'yes' then it doesn't overwrite the existing file, isn't it? How could I config Wix to overwrite one file and not overwirte another?
Some articles about KeyPath:
what-is-the-wix-keypath-attribute
copy-if-not-exist-in-wix

If you are doing this with a majorupgrade element you need to tell us where it's scheduled. If it's "early" (such as afterInstallInitialize) then everything will be uninstalled first, and then the new upgrade installed, and every file that was installed will be from the new upgrade. If it's sequenced "late" (such as afterInstallExecute) then the overwrite rules apply (such as this https://msdn.microsoft.com/en-us/library/windows/desktop) and that's because the upgrade basically installs each file over the existing files.
Note that the WiX default for the MajorUpgrade schedule is afterInstallValidate, so as I described (and as the WiX documentation says) the entire older product will be uninstalled first (obviously removing all files) then all the new files will be installed.
See schedule here:
http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html
The explanation at the WiX keypath link leaves a lot to be desired. It is not really true to say that if the component is present none of its resources will be installed. It's not clear to me what that is intended to mean because the overwrite rules will be applied.
As far as your data files are concerned, they will not be overwritten by an incoming file if they have been updated since they were installed. So it's likely that your ini file is being overwritten because it hasn't been changed. If your db has been updated then it won't be replaced, but, again, this is overwrite rules when your major upgrade is "late" (or it's a patch).

Related

How to make changing MSI install folder work in WiX?

I created a MSI installer to install per-user.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product
Id="*"
Language="1033"
Manufacturer="my company"
Name="my software"
UpgradeCode="{9B85A1B0-6914-4573-92C1-27A6DB849E1D}"
Version="2.0.0.0">
<Package
Compressed="yes"
Description="a software"
InstallerVersion="500"
InstallScope="perUser"
Manufacturer="my company"
Comments="copyright" />
<MediaTemplate EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="AppDataFolder">
<Directory Id="ManufacturerFolder" Name="MyCompany">
<Directory Id="INSTALLFOLDER" Name="MySoftware">
</Directory>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="ManufacturerFolder">
<Component Id="cmp_manufacturer" Guid="{264B9740-7BF6-4D90-9F0A-5B9489687C96}">
<RegistryValue
Root='HKCU'
Key='Software\MyCompany\MySoftware\Product'
Name='reg_manufacturer'
Value='manufacturer'
Type='string'
KeyPath='yes' />
<RemoveFolder Id="removeManufacturerFolder" On="uninstall" />
</Component>
</DirectoryRef>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp_install" Guid="{0CF4AFFB-9676-4944-BCE7-9B0F54704677}">
<RegistryValue
Root='HKCU'
Key='Software\MyCompany\MySoftware\Product'
Name='reg_install'
Value='install'
Type='string'
KeyPath='yes' />
<File Id="file_install" Source="installfile.txt" />
<RemoveFolder Id="removeInstallFolder" On="uninstall" />
</Component>
</DirectoryRef>
<UIRef Id="WixUI_InstallDir" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<Feature
Id="MainFeature"
Title="My Software"
Level="1">
<ComponentRef Id="cmp_manufacturer" />
<ComponentRef Id="cmp_install" />
</Feature>
</Product>
</Wix>
It works well if using default install folder C:\Users\xxx\AppData\Roaming\MyCompany\MySoftware. The file installfile.txt can be removed on uninstall. If I changed the install folder to a different folder using the WiXUI, the file installfile.txt can be copied to the right folder, But the copied file cannot be removed on uninstall. So why that file cannot be removed on uninstall, how to fix this?
I'll appreciate any help.

WIX Single Package Installer - Per machine Shortcuts

I followed this for getting a functioning Per-User/Per-machine installer working using ALLUSERS=2. Now, my issue is regarding getting shortcuts working properly with this setup. If I set MSIINSTALLPERUSER=1 (Single User) then my Desktop and StartMenu shortcuts are always added per user in the HKCU. If I set MSIINSTALLPERUSER={}, then I can get shortcuts per machine. In the custom UI, MSIINSTALLPERUSER is being set based on the selected radio button in the advanced portion of the UI. So, although the shortcuts are created last and their registry values are set to HKMU, the installer always chooses where to put the shortcuts based on the initial value of MSIINSTALLPERUSER.
Can anyone point me in the right direction to properly creating shortcuts based on the type of install selected in the advanced UI (Per User / Per Machine).
Here is my Product.wxs
`
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="HearCon" Language="1033" Version="2.0.299" Manufacturer="Tremetrics" UpgradeCode="73765816-7ba9-4a2b-89c3-ce1f26863b53">
<Package InstallerVersion="500" Compressed="yes" />
<MediaTemplate EmbedCab="yes" />
<Condition Message="Only Windows 7 and newer are supported">
<![CDATA[Installed OR VersionNT >= 601]]>
</Condition>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="Application" Level="1">
<ComponentGroupRef Id="HearConGroup" />
<ComponentRef Id="RA660Folder_Permission" />
</Feature>
<Feature Id="DesktopShortcutFeature" Title="Desktop Shortcut" Level="1">
<ComponentRef Id="DesktopShortcut" />
</Feature>
<Feature Id="StartMenuShortcutFeature" Title="Start Menu Shortcut">
<ComponentRef Id="ProgramMenuShortcut" />
<Condition Level="1">Privileged</Condition>
</Feature>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="HearCon" />
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
<Directory Id="ProgramMenuFolder" />
<Directory Id="CommonAppDataFolder">
<Directory Id="RA660Folder" Name="RA660">
<Directory Id="RA660Driver" Name="Drivers" />
</Directory>
</Directory>
</Directory>
<Property Id="WixAppFolder" Value="WixPerUserFolder" />
<Property Id="ApplicationFolderName" Value="HearCon" />
<Property Id="ALLUSERS" Value="2" />
<Property Id="DISABLEADVTSHORTCUTS" Value="1" />
<Property Id="MSIINSTALLPERUSER" Value="1" />
<UIRef Id="WixUI_CustomAdvanced" />
<WixVariable Id="WixUIBannerBmp" Value="HearConBanner.bmp" />
</Product>
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="10E3E42D-8B2E-471D-A6F9-6263C3491D4C">
<RegistryValue Root="HKMU" Key="Software\Tremetrics\HearCon" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="ProgramMenuFolder">
<Component Id="ProgramMenuShortcut" Guid="2C7EA878-B1B1-4B64-937A-6B583ED5E9B3">
<RegistryValue Root="HKMU" Key="Software\Tremetrics\HearCon" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="RA660Folder">
<Component Id="RA660Folder_Permission" Guid="0A538414-E53F-470E-9546-7EF193878F05">
<CreateFolder>
<util:PermissionEx User="Users" GenericAll="yes"/>
</CreateFolder>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
`

WIX copying files harvested by heat, but does not create cab file

Fairly new to Wix. I have a working msi, but instead of a cab file next to the msi file, I am just getting a folder. I have spent several days trying to figure out why it is not putting the files in a cab file but I am completely at a loss.
The msi file performs exactly as I expect, but distributing the msi alongside a folder is less desirable than just the msi.
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="[Name]" Language="1033" Manufacturer="[Manufacturer]" Version="2.0.30"
UpgradeCode="af66ae21-61e4-4926-954d-ee89acf95ab3">
<Package InstallerVersion="200"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [Name] is already installed." />
<MediaTemplate/>
<Feature Id="ProductFeature" Title="[Title]" Level="1">
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentGroupRef Id="WebApp" />
<ComponentGroupRef Id="ControlApp" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="ManufacturerName" Name="[Name]">
<Directory Id="INSTALLLOCATION" Name="[Name]" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="[Name]"/>
<Directory Id="DesktopFolder" Name="Desktop"></Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="844b584d-6d5f-4825-9541-c7caf74892fb">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="[Name]"
Description="[Name]"
Target="[INSTALLLOCATION]MyApp.exe"
WorkingDirectory="INSTALLLOCATION" />
<RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Name]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop" Guid="629d0ac6-8c63-4309-af33-975925584d1f">
<Shortcut Id="ApplicationDesktopShortcut"
Name="[Name]"
Description="[Name]"
Target="[INSTALLLOCATION]MyApp.exe"
WorkingDirectory="INSTALLLOCATION" />
<RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Name]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
Set the Package/#Compressed attribute to yes.

WIX Create All Users Shortcut without Registry Key

I have a WIX file which i'm using to to install an app and create two short cuts. One in all users start menu and one in the desktop.
Since it creates it's stuff in all users I thought that you didn't need to have a reg key.
But without it it complains.
with
error LGHT0204: ICE38: Component ProgramMenuAppFolder installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
With HKLM however it also complains that the
LGHT0204: ICE38: Component ProgramMenuAppFolder installs to user profile. It's KeyPath registry key must fall under HKCU.
Even though it's installing to the all users and so shouldn't be installing to the user profile.
Any suggestions?
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="$(var.PublisherSimple) $(var.AppName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Publisher)" UpgradeCode="$(var.ProductUpgradeCode)">
<Package
Description="$(var.PublisherSimple) $(var.AppName) $(var.ProductVersion)"
InstallerVersion="200" Compressed="yes"
InstallScope="perMachine"
/>
<Property Id="DISABLEADVTSHORTCUTS" Value="1" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate CompressionLevel="none" />
<Feature Id="ProductFeature" Title="$(var.PublisherSimple) $(var.AppName) $(var.ProductVersion)" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ProgramMenuDir"/>
<ComponentRef Id="ProgramMenuAppFolder"/>
</Feature>
<UI>
<UIRef Id="WixUI_InstallDir" /> <!-- actually uses but that just skips the licence page <UIRef Id="WixUI_InstallDir_Custom" />-->
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<!--<Property Id="WixAppFolder" Value="WixPerMachineFolder" />-->
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.AppName)" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<Property Id="WixShellExecTarget" Value="[#MVTestApp.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="PublisherDirectory" Name="MV">
<Directory Id="INSTALLFOLDER" Name="MV Test App"/>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="Programs">
<Directory Id="ProgramMenuDir" Name="MV" >
<Directory Id="ProgramMenuAppFolder" Name="MV Test App Folder">
<Component Id="ProgramMenuAppFolder" Guid="3ebfd81d-08b2-4bcf-8c90-e84241a58976">
<RemoveFolder Id="ProgramMenuAppFolder" On="uninstall" />
<!--<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />-->
</Component>
</Directory>
<Component Id="ProgramMenuDir" Guid="f1cf94bf-5e5a-4c60-8729-65bdf1cb9244">
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
<!--<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]Start" Type="string" Value="" KeyPath="yes" />-->
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents">
<Component Id="MVTestApp.Exe" Directory="INSTALLFOLDER" Guid="*" Win64="no">
<File Id="MVTestApp.Exe" KeyPath="yes" Source="MVTestApp.Exe" />
<Shortcut Id="startmenuShortCut" Directory="ProgramMenuAppFolder" Name="MV Test App Short Start" WorkingDirectory="INSTALLFOLDER" Advertise="yes" />
<Shortcut Id="desktopShortCut" Directory="DesktopFolder" Name="MV Test App Short Desk" WorkingDirectory="INSTALLFOLDER" Advertise="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
This is a similar problem as Install optional desktop shortcut for all users

Uninstall of wix installer seems to do a repair instead of uninstalling

I have a project which uses wix to generate an install package. The install works fine, but when one tries to uninstall the project, everything looks nice - but after the unistall finishes the product ist still there (still functioning). The entry in add/remove programs disappears when uninstalled from there, but comes back after a refresh (F5). Testers have found that everything looks like the uninstall actually does a repair.
What are we doing wrong (the project otherwise only generates further component fragment files with "heat" (with HeatDirectory-Entries in the wixproj), and defines a few preprocessor variables)?
Here's the product.wxs. Sorry, I know thats a lot of code, but I do not know what I can safely omit to find the problem...:
<?xml version="1.0" encoding="UTF-8"?>
<?define ProductVersion=1.1.0.0?>
<?define UpgradeCode=$(var.UpdateCode)?>
<?define ProductName=$(var.PV) Name?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="xyz" UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" />
<SetProperty Id="REINSTALL" Value="ALL" After="FindRelatedProducts" >Installed AND Remove<>"ALL"</SetProperty>
<SetProperty Id="REINSTALLMODE" Value="vamus" After="FindRelatedProducts">Installed AND Remove<>"ALL"</SetProperty>
<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="XY Installer" Level="1" ConfigurableDirectory="INSTALLLOCATION">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="DesktopShortcutComponentGroup"/>
<ComponentGroupRef Id="StartmenuShortcuts"/>
</Feature>
<CustomAction Id="RestoreDatabase" Directory="INSTALLLOCATION" ExeCommand="[INSTALLLOCATION]initial_db\BURestore.exe $(var.Sport)_$(var.Project) D:\$(var.Sport)\initial_db\db.bak" Execute="deferred" Return="ignore" HideTarget="no" Impersonate="no" />
<CustomAction Id="RenameFormatFilesFolder" Directory="LISTTOOLLOCATION" ExeCommand="cmd /c "mv FormatFiles fmt"" Return="ignore" Impersonate="yes"></CustomAction>
<InstallExecuteSequence>
<Custom Action="RestoreDatabase" Before="InstallFinalize">NOT REMOVE</Custom>
<Custom Action="RenameFormatFilesFolder" After="InstallFinalize">NOT REMOVE</Custom>
</InstallExecuteSequence>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION"/>
<UI>
<UIRef Id="WixUI_InstallDir"/>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">1</Publish>
</UI>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ROOTDIR" Name="D"/>
<Directory Id="INSTALLLOCATION" Name="$(var.PV)">
<Directory Id="CONF" Name="conf">
<Directory Id="LISTTOOLLOCATION" Name="PRINT"></Directory>
</Directory>
</Directory>
<Directory Id="DesktopFolder" />
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="ST">
<Directory Id="ApplicationFolder" Name="$(var.ProductName)" />
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLLOCATION">
<ComponentGroupRef Id="RootFiles" />
<ComponentGroupRef Id="ListToolFiles" />
<ComponentGroupRef Id="inis" />
</ComponentGroup>
<ComponentGroup Id="DesktopShortcutComponentGroup">
<Component Id="DesktopShortcutComponent" Guid="{C54B....}" Directory="DesktopFolder">
<Shortcut Id="ApplicationDesktopShortcut"
Name="$(var.ProductName)"
Description="$(var.ProductName) Application"
Target="[INSTALLLOCATION]RO.exe"
WorkingDirectory="INSTALLLOCATION"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\ST\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</ComponentGroup>
<ComponentGroup Id="StartmenuShortcuts" Directory="ApplicationFolder">
<Component Id="StartmenuShortcutComp" Guid="{ACD9...}">
<Shortcut Id="StartmenuShortcut" Name="$(var.ProductName)" Description="$(var.ProductName) Application" Target="[INSTALLLOCATION]RO.exe" WorkingDirectory="INSTALLLOCATION" />
<Shortcut Id="UninstallProduct" Name="Uninstall $(var.ProductName)" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" Description="Uninstalls $(var.ProductName)" />
<RemoveFolder Id="RemoveProgramMenuSubfolder" Directory="ProgramMenuSubfolder" On="uninstall"/>
<RemoveFolder Id="RemoveApplicationFolder" Directory="ApplicationFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\ST\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
The below two lines are making this issue.
<SetProperty Id="REINSTALL" Value="ALL" After="FindRelatedProducts" >Installed AND Remove<>"ALL"</SetProperty>
<SetProperty Id="REINSTALLMODE" Value="vamus" After="FindRelatedProducts">Installed AND Remove<>"ALL"</SetProperty>
That condition become true because Remove will be set ALL in Uninstall after InstallValidate action in Install execute sequence. Please check below link for more details.
https://msdn.microsoft.com/en-us/library/aa368013(v=vs.85).aspx