views:

1097

answers:

1

For a .NET application installed using ClickOnce, is there any way to run a custom action during the uninstall process.

Specifically, I need to delete a few app related files (which I created on first run) and call a web service during the uninstall process.

Any ideas?

+1  A: 

There is no way to do that with ClickOnce itself, but you can create a standard Setup.exe bootstrapper that installs the ClickOnce application and which has a custom uninstall action.

Note that this however this creates two entries in the Add /Remove programs, so you need to hide one of the entries (the clickonce app).

Your final problem will then be that there is no "silent uninstall" option on clickonce, so you could do something like this:

On Error Resume Next 

Set objShell = WScript.CreateObject("WScript.Shell")

objShell.Run "taskkill /f /im [your app process name]*"

objShell.Run "[your app uninstall key]"
Do Until Success = True
    Success = objShell.AppActivate("[your window title]")
    Wscript.Sleep 200
Loop
objShell.SendKeys "OK"

(Found here)

Espo