Results 1 to 5 of 5

Thread: [2008] How to run a file upon uninstall ?

  1. #1

    Thread Starter
    Addicted Member kaisellgren's Avatar
    Join Date
    Jan 2006
    Posts
    149

    [2008] How to run a file upon uninstall ?

    Hello,

    I have a setup project on VS 08 and I am asking how can I run a .exe file during uninstall?

    The exe removes two registry keys my program may create so I need to include this additional uninstall .exe file to make sure no registry keys are left behind uninstallation.

    I tried: Custom Actions -> Uninstall -> and added my uinstall.exe file but still it did not launch upon uninstallation :S

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] How to run a file upon uninstall ?

    You would do it with a Custom Action. If you don't know how to use them properly then I suggest a visit to MSDN for some reading on the subject.

    Basically you should create a new class library project and add an InstallerClass to it. You then add an event handler for the appropriate event, e.g. AfterUninstall. You then add that as your Custom Action and when your app's uninstaller raises that event your method will be executed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member kaisellgren's Avatar
    Join Date
    Jan 2006
    Posts
    149

    Re: [2008] How to run a file upon uninstall ?

    Hmm I am not sure what you exactly mean by that.

    I am using the 'Setup' from the 'New Project' list where you can select New Form, New Project, New DLL, etc...

    Here's a screenshot of a file I included in my setup and the file itself works I have tried, however, it's never being launched during uninstallation


  4. #4
    Fanatic Member Clanguage's Avatar
    Join Date
    Jan 2008
    Location
    North Carolina
    Posts
    659

    Re: [2008] How to run a file upon uninstall ?

    You need to write the code for that. If you look at
    Code:
    System.Configuration.Install.Installer
    class there are 2 events that you can use BeforeUninstall and AfterUninstall where you can call an exe or a batch file from there.
    CLanguage;
    IF Post = HelpFull Then
    RateMe
    Else
    Say("Shut UP")
    End If
    DotNet rocks
    VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] How to run a file upon uninstall ?

    I know you're creating a Setup project. I said you need to create ANOTHER project, this time a Class Library. To it you add an InstallerClass. In that InstallerClass you handle the appropriate event. You then add that InstallerClass to your Setup project via the Custom Actions editor.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width