Search code examples
windows-installerinstallshield

InstallShield: How to remove files and subfolders that MSI doesn't know when uninstalling a program?


I'm using InstallShield 2019 Professional Edition and have a Basic MSI Project which contains an executable program.

My program creates some files and subfolders (log, environment, ...) in the installation folder during the execution.

Of course, MSI doesn't know about the existence of these files and their subfolders. Therefore, after a user has deleted the program, these files and folders remain on the computer.

Is there any option to empty the installation directory in the Basic MSI Project?

I found a question similar to this on Stack Overflow. But the link in this answer doesn't work anymore. For that reason, I asked the question again.


Solution

  • If the files and folders to be deleted are a known quantity, you can use the RemoveFile table to specify files and folders to remove. InstallShield shows this under components in the Advanced section or in the direct editor.

    https://learn.microsoft.com/en-us/windows/win32/msi/removefile-table

    If your files are in an unknown directory structure you'll have to write a custom action.

    As an aside, sometimes if you change your application to put these files under C:\ProgramData ([CommonAppDataFolder]) instead of C:\Program Files people become less sensitive about stuff being left behind.

    If being left behind feels 'dirty' to you consider that it is a design guide from Microsoft to leave user data behind on uninstall.