Thursday, April 2, 2009

Uninstalling run-time-created files

In a Basic MSI project, there are three ways to uninstall run-time-created files:

  1. You can create a dummy file that has the same name as the file created at run-time. There doesn't have to be any information in the file. Generally, I just put the words "Dummy File" or "Placeholder" in the file and save it out. Add this file to a component in your installation, rebuild and test. The installer will install the file. When you run the application, it will overwrite the file. Then when you uninstall, the file will be deleted, because InstallShield installed it originally. Personally, I use this method almost exclusively. It works when you have a small number of files to work with.
  2. You can create an InstallScript Custom Action which deletes the file or folder of files. Place a condition on the Custom Action such that it is only run during uninstallation. Then, add it to the User Interface sequence after ExecuteAction. This works. Some may not consider this very elegant, but it does work.
  3. Add the file(s) to the RemoveFile table. This is a little more complicated, so you'll have to consult the InstallShield Help. If you are a Basic MSI or Windows Installer purist, you will probably like this solution the best.

That's it. Three ways to get rid of files created at run-time.

No comments:

Post a Comment