BoyUnderTheMoon
BoyUnderTheMoon

Reputation: 771

WiX: Deleting files and subfolders in appdata folder

I've extensively searched for an answer on how to do this and although i've come across a few answers they were either not specific enough or too advanced for my WiX knowledge.

How can I delete the folders, files and subfolders (as well as the parent folder) in the appdata folder that is created by the application (not installer) while using the WiX uninstaller.

Using the control panel to uninstall the application will delete the folder within AppData, however, this is not the case when the installer is used to uninstall the application.

Any help would be greatly appreciated.

I currently have:

<Property Id="APPLICATIONFOLDER">
    <RegistrySearch Root="HKCU" Key="Software\AppCo\AppName" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="PrivateDir" />
</Property>

<DirectoryRef Id='PrivateDataFolder'>
    <Component Id="PrivateData" Guid="*">
        <CreateFolder Directory="PrivateDataFolder"/>

        <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />

        <RemoveFolder Id="PrivateDataFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\AppCo\AppName" Name="PrivateDir" Type="string" Value="[PrivateDataFolder]" KeyPath="yes"/>
    </Component>
</DirectoryRef>

However, this doesn't seem to be working.

Edit2: Some files will be removed within the folder, but the entire folder and subfolders will not be removed.

Upvotes: 0

Views: 2120

Answers (1)

Rick Bowerman
Rick Bowerman

Reputation: 1884

Use RemoveFolderEx with a component assigned to the parent folder in AppData. Bob Arnson discusses it further here. Be aware that you can't use an assigned directory so creating a registry key to get the path to the AppData folder you wish to delete will be prudent. Make sure you include UtilExtension in your project.

Upvotes: 0

Related Questions