Closed alicera closed 1 year ago
Hello @alicera,
without some sample code it is difficult to say what the problem is.
Remarks at https://wixtoolset.org/documentation/manual/v3/xsd/util/removefolderex.html suggest that:
In the sample article you linked APPLICATIONFOLDER
was indeed read from registry. Are you doing the same?
Alternatively, if you just want to delete some files and not the entire folder, you can instead use https://wixtoolset.org/documentation/manual/v3/xsd/wix/removefile.html
hi @kurtanr Thanks for your reply.
I try install it with msi and create a folder 0 by myself Then remove the app, the folder can not clear up. There is a 0 folder exist
Here is the code that I reproduce and I reference this https://www.hass.de/content/wix-how-use-removefolderex-your-xml-scripts https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with
you can get the icon with https://www.codeproject.com/favicon.ico I create the example.exe (fake).
I build it with the command
"C:/Program Files (x86)/WiX Toolset v3.11/bin/candle.exe" -ext WixUtilExtension example.wxs && "C:/Program Files (x86)/WiX Toolset v3.11/bin/light.exe" -ext WixUtilExtension example.wixobj
example.wxs
<?xml version="1.0"?>
<?define ProductVersion = "0.0.1"?>
<?define ProductUpgradeCode = "12345678-1234-1234-1234-111111111111"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)"
Name="Example Product Name" Version="$(var.ProductVersion)" Manufacturer="Example Company Name" Language="1033">
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Icon Id="ProductIcon" SourceFile="favicon.ico"/>
<Property Id="ARPPRODUCTICON" Value="ProductIcon"/>
<Property Id="ARPHELPLINK" Value="http://www.exampleproduct.com"/>
<Property Id="ARPURLINFOABOUT" Value="http://www.examplecompany.com"/>
<Property Id="ARPNOREPAIR" Value="1"/>
<Property Id="ARPNOMODIFY" Value="1"/>
<Upgrade Id="$(var.ProductUpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Minimum="0.0.0" Maximum="$(var.ProductVersion)" IncludeMinimum="yes" IncludeMaximum="no"
Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>
<Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition>
<Property Id="APPLICATIONFOLDER">
<RegistrySearch Key="Software\Example Company Name\Example Product Name" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
</Property>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Example">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
<File Id="ApplicationFile1" Source="example.exe"/>
</Component>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="Example">
<Component Id="ApplicationShortcuts" Guid="12345678-1234-1234-1234-333333333333">
<Shortcut Id="ApplicationShortcut1" Name="Example Shortcut Name" Description="Example Product Name"
Target="[INSTALLDIR]example.exe" WorkingDirectory="INSTALLDIR"/>
<RegistryValue Root="HKCU" Key="Software\Example Company Name\Example Product Name"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/>
</Component>
<Component Id="CleanupMainApplicationFolder" Guid="0ffde969-e17c-4708-a7fd-3e0dfacab6b0">
<RegistryValue Root="HKCU" Key="Software\Example Company Name\Example Product Name" Name="Path" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes" />
<!-- We need to use APPLICATIONFOLDER variable here or RemoveFolderEx
will not remove on "install". -->
<util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
</Component>
</Directory>
</Directory>
</Directory>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="ApplicationFiles"/>
<ComponentRef Id="ApplicationShortcuts"/>
<ComponentRef Id="CleanupMainApplicationFolder" />
</Feature>
</Product>
</Wix>
install it with msi and create a folder 0 by myself _ uninstall it
0 exist , not remove
Hello @alicera,
one thing I've noticed is that RegistrySearch
targets Root="HKLM"
and in RegistryValue
you are targeting Root="HKCU"
.
Also, your code does not really follow the example from https://www.hass.de/content/wix-how-use-removefolderex-your-xml-scripts where XML structure is quite different (e.g. RemoveFolderEx
is under the DirectoryRef
component).
I also suggest you install / uninstall the installer with logging enabled (/L*V
) and you should get more information regarding the problem.
A :
A <Property Id="APPLICATIONFOLDER">
B <DirectoryRef Id="APPLICATIONFOLDER">
Hello @alicera,
RegistrySearch
and in RegistryValue
.Anyway, since this issue is not really related to any of the examples / articles in this repository, I am closing the issue.
Thanks your help
Do you meet the status?
When I upgrade my program with wix, I found the
I expect the uninstall step not the upgrade.
Do you have any idea?
Hello @alicera,
during major upgrade previous version of the application if first uninstalled and then the new version is installed ('Schedule' property has some more information about that). This is why folders are deleted on upgrade.
I reference the major upgrade. I set Schedule as afterInstallInitialize.
At the same condition, I try to use
<RemoveFile Id="FILE" Directory="log" Name ="*.*" On ="uninstall"/>
<RemoveFolder Id="FOLDER" Directory="log" On="uninstall"/>
and
<util:RemoveFolderEx On="uninstall" Property="INSTALLDIR"/>
The util:RemoveFolderEx will be trigger when uninstall and upgrade. The RemoveFolder and RemoveFile will be trigger when uninstall.
https://www.hass.de/content/wix-how-use-removefolderex-your-xml-scripts
I follow this to remove program. After install the program with msi, I add some file into the folder. Then I remove it with msi , the files that I add still exist. It can not be removed. Do you know why? thank