How do I prevent Windows Installer from removing a file (or registry key) on uninstall?
By default, Windows Installer uninstalls all files that are installed during the initial install. Preventing the removal of an installed file can be done at the component level, but not at the file level. There are two different ways to accomplish this either by modifying the Component table directly, or modifying the Component details.
To modify the Component table, follow these steps:
- Select the Component table from the Tables tab in Setup Editor, and highlight the Attributes column of the component that is to be left on the machine during the uninstall.
- Change the value in the Attributes column to 16 for the component to keep during the uninstall. Press the <Tab> key to update the field.
To modify the Component Details, follow these steps:
- Determine which component contains the file in question; go to the Setup Editor and click on the Components tab.
- Locate the appropriate component, right-click on it, and select Details.
- In the Component Details dialog, mark the "Leave installed on uninstall" checkbox.
Both of these approaches will leave the entire contents of a component installed after an uninstall. To leave just a single file installed after uninstall, you may need to create a new component (which would contain only the file in question) and follow the steps above to flag it as permanent.