Uninstall ClickOnce clients
Asked Answered
L

2

26

Since ClickOnce installs per profile rather than per computer, is there any way to uninstall a single ClickOnce client application from multiple profiles at the same time?

We have a ClickOnce application that we would like to remove and re-install using a standard MSI, but we don't want to have to log in as each user to do the uninstall.

Assuming there isn't anything baked in, is there a custom tool?

Lisbethlisbon answered 12/8, 2009 at 15:16 Comment(0)
D
47

You could manually delete the ClickOnce install for each user. I haven't tried doing this on a large scale, so use at your own risk. However, these steps should get rid of a ClickOnce app.

  • Delete the deployed files. On my machine, the path to my ClickOnce deployed files is, %UserProfile%\AppData\Local\Apps\2.0. If you delete everything under this folder, it will delete all ClickOnce applications. Obviously, you'd need to do this for each user profile.

  • Delete the start menu shortcut. Again, this needs to be done for each user profile.

  • Now all that's left is an entry in Add/Remove programs. I think removing this is optional since it doesn't really hurt anything, but to get rid of it you can delete registry entries. Go through the users under HKEY_USERS and delete this key, Software\Microsoft\Windows\CurrentVersion\Uninstall\[random string associated with your app].

Dickinson answered 13/8, 2009 at 14:47 Comment(4)
Thanks - this is the only click once app, so I think the above instructions should work.Lisbethlisbon
I know this is an old question, but for reference of future viewers you may also want to kill any processes that are using the Clickonce App files, otherwise an error will be thrown.Gabriel
If you don't want to delete all the ClickOnce apps you can just delete the folders that are associated with your app under 2.0. But there is also a /manifest folder under /2.0/.../ where the app is referenced again.Wey
For most users, Google Chrome is a ClickOnce application, so I would recommend scanning for your ClickOnce folder and only deleting that.Notecase
P
0

Usually, I use the below vb.net function to Uninstall our ClickOnce applications on our user's PCs. I hope this help you. You can convert to C# here if you use C#.

Private Sub KillandClear()
        Try
            Me.Cursor = Cursors.WaitCursor

            '************* Killing the current running process *************
            Dim proce2 As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("****YourApp****")
            For Each process In proce2
                process.Kill()
            Next


            '************* Deleting the Local Appdata *************
            Dim rootFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\Apps\2.0"
            Dim foldersToDelete As List(Of String) = Directory.GetDirectories(rootFolder, "YourApp*", SearchOption.AllDirectories).ToList()

            For Each folder In foldersToDelete
                Directory.Delete(folder, True)
            Next

            '************* Clearing the Registry *************
            Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", True)
            Dim subKeys() As String = regKey.GetSubKeyNames()

            For Each subKey In subKeys
                Dim appKey As RegistryKey = regKey.OpenSubKey(subKey, True)
                Dim uninstallString As String = appKey.GetValue("UninstallString")

                If uninstallString IsNot Nothing AndAlso uninstallString.Contains("****YourApp****") Then
                    regKey.DeleteSubKeyTree(subKey)
                End If
            Next

            '************* Deleting the Desktop Shortcuts *************
            For Each FName As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.Desktop)
                If FName.StartsWith("****YourApp****") Then
                    My.Computer.FileSystem.DeleteFile(FName, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
                End If
            Next
        Catch ex As System.Exception
            'MessageBox.Show("Error Message:" & vbCrLf & ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub
Passant answered 13/6, 2023 at 6:28 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.