views:

55

answers:

2

Hey everyone. 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

+1  A: 

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

Giorgi
@Skoder: here you have pretty much everything you need to know about custom actions http://stackoverflow.com/questions/321867/visual-studio-2008-installer-project-custom-actions-not-firing
Stefan Egli
Thanks for the help. I'm not quite sure of one thing. Which class to I have inherit from `Installer`? I'm running a WPF application and am not sure where to override the Uninstall method.
Skoder
You might want to read this before writing an Install Util custom action. http://robmensching.com/blog/posts/2007/4/19/Managed-Code-CustomActions-no-support-on-the-way-and-heres
Christopher Painter
@Christopher - does RemoveFiles support file path that is determined at runtime (such as SpecialFolder.CommonApplicationData)? Also, I suggest you look at the followinf blog post http://robmensching.com/blog/archive/2008/05/16/Deployment-Tools-Foundation-joins-the-WiX-toolset.aspx which is continuation of the blog post you recommended.
Giorgi
I am well aware of DTF ( and love it ); it's InstallUtil ( Installer Class ) that I dislike.Regardless, I'd rather read my own blog: http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html And yes, Windows Installer supports that well known folder: http://msdn.microsoft.com/en-us/library/aa367992(VS.85).aspx
Christopher Painter
@Giorgi - I suggest reading: http://robmensching.com/blog/archive/2007/08/17/Zataoca-Custom-actions-are-generally-an-admission-of-failure.aspx
Christopher Painter
@Christopher - Thanks for the links it was really interesting. I have misunderstood your first comment so I'm sorry if my reply was rood.
Giorgi
+1  A: 

Windows Installer has the RemoveFiles table for just this purpose. Unfortunatly the tool you've choosen doesn't expose this ( or many other ) feature. I suggest looking into another tool such as Windows Installer XML. Otherwise you'll be rolling fragile custom action antipatterns to work around the limitation.

Christopher Painter
Thanks for the suggestion, but I'm afraid I have to use MSI for this purpose. I find it hard to believe that such an option of removing other files created by your application has to be shoe-horned in almost and not just a standard option like the other settings.
Skoder
Visual Studio Deployment Projects (Setup Project) is simply one of many authoring tools for creating Windows Installer ( MSI ) packages. The problem isn't with MSI, the problem is with the horrible tool that Microsoft included with Visual Studio for free. The tool fails to expose this and many other capabilities of MSI forcing you to reinvent the wheel.
Christopher Painter