Uninstall my application

Wilfred Eghenedji 326 Reputation points
2023-08-17T12:07:51.2433333+00:00

I want to uninstall my application(named, "EasyShut") through button. Am using VB.Net. Would like the application users to be able to easily uninstall the app from within the app, instead of going into control panel to do that. Already, I stumbled on a post by "Dasaradhi_r" on "codeproject.com" but doest seem working. It does nothing when I click. Can someone help fix this or alternatively proffer another but a working solution. Thank you:

    Private Sub UninstallToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles UninstallToolStripMenuItem1.Click
    Dim info As ProcessStartInfo = New ProcessStartInfo()
    Dim uninstallProcess As Process = New Process()
    Dim ns = rgKey.GetSubKeyNames().Where(Function(n) n.ToLower().Contains("EasyShut"))

    If ns.Count() > 0 Then

        For Each vsKey In rgKey.GetSubKeyNames()
            Dim productKey As RegistryKey = rgKey.OpenSubKey(vsKey)
            Dim dispName As String = Convert.ToString(productKey.GetValue("DisplayName"))
            Dim uninstlString As String = Convert.ToString(productKey.GetValue("UninstallString"))

            If dispName.ToLower().Contains("EasyShut") Then
                Dim prdctId As String = uninstlString.Substring((uninstlString.IndexOf("{")))
                uninstallProcess.StartInfo.FileName = "MsiExec.exe"
                uninstallProcess.StartInfo.Arguments = " /x " & prdctId & " /Qn"
                uninstallProcess.Start()
                Exit For
            End If
        Next
    End If
End Sub
    ```

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,832 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.