2

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.

deralbert
  • 856
  • 2
  • 15
  • 33
user2423434
  • 199
  • 1
  • 3
  • 21
  • 1
    No, there's no way to do that, and you shouldn't anyway. The uninstaller has no way of knowing anything about those files, and leaves them intentionally. What happens if the user puts something unrelated to your app in that same folder? What happens if the user spends lots of time setting up your app, decides to uninstall and reinstall because of a problem, and your uninstaller deletes all of their data? There's a reason that uninstallers only removes things that the installer puts there. – Ken White Jan 06 '20 at 02:33
  • 1
    Is the number of subfolders fixed and know? ([INSTALLDIR]Logs [INSTALLDIR]Data) – Christopher Painter Jan 06 '20 at 20:37
  • 1
    MSI's RemoveFile table can be told to remove file(s) and a folder but it can't handle files and folders recursively. That requires a custom action. – Christopher Painter Jan 06 '20 at 20:39
  • Thank you @ChristopherPainter agan. I solved the problem. Can you post this comment to answer? Then I can choose you answer as a solution. – user2423434 Jan 07 '20 at 08:26
  • I published an answer. – Christopher Painter Jan 07 '20 at 14:50

1 Answers1

4

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.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100