How do I prevent a file or registry entry from being uninstalled or repaired?

OrganizationYou need to modify some of the resource's component attributes, in the "Organization" page.

  • to prevent it from being repaired check the "Never Overwrite" attribute

Caution!If a registry entry is a key resource in its component, it cannot have the "Never Overwrite" attribute enabled.

  • to prevent it from being uninstalled check the "Permanent" attribute

However, this method has some drawbacks. By using it, the resource has to be manually repaired or deleted by the user if it gets corrupted.

TipAn alternative to checking the "Permanent" attribute for each file's component is to enable their parent folder preserve operation with REMOVE="ALL" condition from the Files and Folders Page.

ImportantIf you already released a version without using these options but want to prevent a file from being overwritten you could enable its preserve operation with OLDPRODUCTS condition from the Files and Folders Page. The same operation is also available for a registry key or a folder's contents.

As a general idea, it is not recommended to use the installed file to store any user data. The best way would be for the application to create a new file that stores it. At the simplest form, this method would consist of simply creating a copy of the installed file and modifying that.

If the application cannot create the file from scratch it should use the installed file as a template for the files that store the user data, meaning that the application uses the installed files as a starting point. It merges the user data with the template data to create the new file.