views:

64

answers:

2

Can I reliably initiate the un-installation of a ClickOnce app, from within the app?

In other words, I want to give the user a big "Uninstall Me Now" button on one of the forms. When a user clicks the button, I want to start the windows uninstall process for this app, and perhaps close the app.

Reason: We are dead-ending a ClickOnce app and want to make it as easy to remove as it was to install. We don't want to send them down the path to "Add or Remove Programs" and risk them getting lost or distracted.

Can this be done reliably?

A: 

Have a look at this thread: http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/4b681725-faaa-48c3-bbb0-02ebf3926e25

It gives the link to the following blog, where the code uninstalls the application, and then re-installs the application, you could probably want just to uninstall. have a look at it.

http://www.jamesharte.com/blog/?p=11

anantmf
+2  A: 

I'd recommend checking out this MSDN article here. It explains how to programmatically uninstall an app (and reinstall from a new URL if you want to):

http://msdn.microsoft.com/en-us/library/ff369721.aspx

This is a variant on the jameshart blog entry, but it includes a couple of fixes that you're going to want to use. There are code downloads in both C# and VB.

In fact, you can just push an update and have the app uninstall itself, you don't even need the user to say "ok".

RobinDotNet