Is there a way to NOT delete files after an uninstall?
4 Answers
Set the Component
value Permanent="yes"
like so:
<Component Id="LicenseDoc" Guid="*" Permanent="yes">
<File Id ="License.rtf" Source="$(var.SolutionDir)Installer\License.rtf" />
</Component>
Remarks:
- This definition has to be done in the installed MSI as well as the upgrading MSI. If the base MSI did not have a component Id this file will be deleted regardless of the
Permanent="yes"

- 5,634
- 3
- 41
- 66

- 22,906
- 3
- 32
- 45
-
7I posted the question to the wixusers mailing list and got the same answer, but also to note about the Permanent flag (compliments of Phil Wilson): As long as everyone realizes that Permanent means permanent forever. It doesn't mean "until I change the setting to not Permanent". It makes that component permanent on the system, and I wouldn't use it unless "permanently installer forever" is what is required. – glenneroo Apr 14 '10 at 10:34
-
I'll revive this topic and ask: what if you have numerous (200+) files that you want to leave? Going to each component and adding Permanent="yes" or setting Guid="" does not feel right. – treaz Jun 25 '14 at 09:48
-
1but that is the way of WiX, you are describing the finite state of each file, so there is zero ambiguity about how the system should be before/after install/uninstall. The problem with older installers is they did not handle all error, thus would be in strange states. MSI is a stateful process. – Simeon Pilgrim Jun 25 '14 at 21:12
-
The correct solution is to compose a proper harvesting script to manage the Permanent flag on the components according to the logic that you dictate. Also note that component Id's should be statically defined in this instance, otherwise changing the file source path will change the component guid and you will end up with undesired behaviour. Putting all files in a single component is a big violation and complicates things beyond reason. – Tamir Daniely Sep 29 '15 at 12:51
-
The harvesting script is called heat.exe and is already preinstalled with WiX. – berkus Dec 10 '15 at 15:38
Compliments of Phil Wilson from wixusers mailing-list:
See the MSI SDK docs for the Component table - set the Component guid to be null (empty). The effect of this is that the component isn't registered (so it can't be repaired) and it won't be uninstalled.

- 1,908
- 5
- 30
- 49
I know this question is old, but I just stumbled across it as I was looking for a way for my installer to install missing fonts, but not uninstall them when the application is uninstalled. Hope it helps someone else who may come across this question. I was a bit uncomfortable with both of the solutions provided (blank/empty Guid or set the component to permanant). So I came up with this, which worked for me:
<Feature Id="myFonts" Title="Application Fonts" Level="1">
<ComponentGroupRef Id="Component_group_with_fonts_to_install" />
<Condition Level="0">
<![CDATA[REMOVE = "ALL"]]>
</Condition>
</Feature>
This way the font feature is installed, but when being uninstalled, the feature's level is set to 0, so it is left alone.

- 357
- 3
- 20
Another way to prevent Windows Installer from deleting the component on uninstall is to set a blank or empty component GUID. This will cause the component to be installed but it will never be tracked or uninstalled.
See the MSI SDK documentation: "...if this column (ComponentId) is null the installer does not register the component and the component cannot be removed or repaired by the installer. This might be intentionally done if the component is only needed during the installation, such as a custom action that cleans up temporary files or removes an old product. It may also be useful when copying data files to a user's computer that do not need to be registered."

- 39,960
- 25
- 91
- 164