Search code examples
c#deploymentwindows-installersetup-projectuninstallation

Uninstall non-setup created files


I have a Setup project (MSI) in VS2008 which installs my project. Within the project, I create a settings file, for the application, in the SpecialFolder.CommonApplicationData + \\"settings" folder (the two slashes are in the C# code for escaping). However, the uninstaller doesn't get rid of this for me when it removes the program. How can I delete this folder during uninstallation? I've read that I should be using VB Script, but I've never used it before so not quite sure how to do it. I tried something like this:

On Error Resume Next
Dim fso, objfolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(COMMON_FILES + "\\settings")
objfolder.Delete
Set folder = nothing
Set fso = nothing

but the setting files are still there after uninstallation. Any ideas? Thanks


Solution

  • Add a custom installer action and override Uninstall method to delete extra files.

    See this article for more information about custom install actions: Installer Class and Custom Actions