Custom action on uninstall (clickonce) - in .NET

前端 未结 2 618
傲寒
傲寒 2020-12-31 12:41

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 rel

2条回答
  •  执笔经年
    2020-12-31 13:09

    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)

提交回复
热议问题