[wix-devs] Clean up directories (possibly with extra non-installed files) on uninstall (but not major upgrade)

Scott Smith wix-devs at scott-smith.us
Fri Apr 2 15:52:48 PDT 2021


- Our app keeps some system-wide configuration files under 
C:\ProgramData\OurAppName, so the install creates that directory and a 
few sub-directories:

   C:\ProgramData
      +- OurAppFolder
         +- Foo1
         |  +- Foo2
         +- Bar1
         |  +- Bar2
         +- Baz1
            +- Baz2

- The configuration files, plus /foo/ and /bar/ and /baz/ files, etc are 
created in the sub-directories at runtime. An uninstall never removes 
any of these directories, because they contain files that weren't installed.

- When a user performs a major upgrade, we'd like to /*not*/ remove the 
configuration information or other files

- But when a user is doing a stand-alone uninstall (vs. nested as part 
of an upgrade), we would like to remove OurAppName and everything underneath


I've found a number of posts about this on stackoverflow, etc, but no 
one seems to have a good solution that doesn't involve a custom action 
(which I'm led to believe are evil).

I've been able to determine that the condition I need is: (NOT 
UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")

I initially bundled a bunch of <RemoveFolder ...> and <RemoveFile ... 
Name="*.*" ...> elements in the component containing the <CreateFolder 
...> elements and the registry setting as the keypath. Of course, that 
just unconditionally removes everything on uninstall; even during a 
major upgrade.

To apply the condition to these operations, I was going to create a 
separate component and condition it on the expression above, but several 
posts pointed out that since this new "component" will never be 
installed, it won't be executed later.

What is the current consensus on how to do this?


Thanks.



More information about the wix-devs mailing list