Uninstall my application
Wilfred Eghenedji
326
Reputation points
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
```
Sign in to answer