Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom action on uninstall (clickonce) - in .NET

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?

like image 716
Sameet Avatar asked Jul 22 '09 05:07

Sameet


1 Answers

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)

like image 117
Espo Avatar answered Oct 11 '22 03:10

Espo