2

I have wix installer with bootstraper for some application what creates additional files in application folder during his work and I have to remove these files during uninstall. According to https://www.hass.de/content/wix-how-use-removefolderex-your-xml-scripts and other same examples I have next parts of code:

  1. Define property:

    <Property Id="APPLICATIONFOLDER">
      <RegistrySearch Key="SOFTWARE\ProductName" 
                      Root="HKLM" 
                      Type="raw" 
                      Id="APPLICATIONFOLDER_REGSEARCH" 
                      Name="Path" />
    </Property>
    
  2. Define component:

    <Directory Id="APPLICATIONFOLDER" Name="ProductName">
      <Component Id="RemoveAll" Guid="some-guid">
        <RegistryValue Root="HKLM" 
                       Key="Software\ProductName" 
                       Type="string" 
                       Name="Path" 
                       Value="[APPLICATIONFOLDER]" 
                       KeyPath="yes"/>
        <util:RemoveFolderEx On="uninstall" 
                             Property="APPLICATIONFOLDER" />
      </Component>
    </Directory>
    
  3. Add component to feature:

    <Feature Id="ProductFeature" Title="ProductName" Level="1">
      ...
      <ComponentRef Id="RemoveAll" />
      ...
    </Feature>
    

Then when I try to uninstall this application I have next lines in wix logs:

...
MSI (s) (B4:64) [13:05:58:798]: PROPERTY CHANGE: Adding APPLICATIONFOLDER property. Its value is 'C:\Program Files(x86)\ProductName\'
...
Action start 13:05:58: WixRemoveFoldersEx.
MSI (s) (B4:48) [13:05:58:914]: PROPERTY CHANGE: Adding _APPLICATIONFOLDER_0 property. Its value is 'C:\Program Files (x86)\ProductName\'.
WixRemoveFoldersEx:  Recursing path: C:\Program Files (x86)\ProductName\ for row: wrfE932DA8DA501DD981493D5D9F4EFDD75.
MSI (s) (B4:64) [13:05:58:918]: Doing action: CostInitialize
MSI (s) (B4:64) [13:05:58:918]: Note: 1: 2205 2:  3: ActionText 
Action ended 13:05:58: WixRemoveFoldersEx. Return value 1.
...

But nothing heppens and all additional files are present in the application folder, and accordingly the folder also is present. I have no idea why and I do not know what need to change to resolve this problem.

Could somebody help me?

Traphic
  • 21
  • 3
  • Did you see [How To Delete Generated Folders/Files?](https://stackoverflow.com/questions/35766359/how-can-i-delete-generated-folders-and-files-via-wix-on-uninstall) – Alexander Aug 30 '18 at 15:00

1 Answers1

-1

You need to remove any files created by the application before the folder can be removed. Try something like this:

<Component Id="RemoveOrphanFiles" Guid=InsertGUID KeyPath="yes">
   <RemoveFile Id="RemoveFiles" Name="*.*" On="uninstall" />
</Component>

and add a condition so that it only runs on uninstall ... Hope this helps!

Sharpenologist
  • 189
  • 1
  • 5
  • 4
    `util:RemoveFolderEx`'s purpose is to remove all files and folders in a folder without knowing all the names. – Alexander Aug 30 '18 at 14:59