Question uninstall multiple programs one by one from a checklistbox

cornelvis

Active member
Joined
Jul 15, 2005
Messages
30
Programming Experience
3-5
Hi,

I was thinking about this project for a long time and now I really want to get to it, because I think windows is really missing this feature and it drives me nuts waiting for it to finish and the select another program or install part of the program until it's finished with the first one...

I try to uninstall multiple programs one by one from a checklistbox.
the filling of the clb was not really difficult, but now the rest.
I tried to write to command line, but somehow this doesn't work with sendkeys......

I think I need to get the installer (msiexec.exe) up and uninstall the selected app by name or do I have to get some id as well?

all ideas are welcome, I'm really stuck and have to delete my code everytime, because I'm thinking the wrong way around.

Here is my code so far:

VB.NET:
Imports Microsoft.Win32



Public Class Form1


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim uninstallkey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(uninstallkey)
        Dim sk As RegistryKey
        Dim skname() = rk.GetSubKeyNames
        clbProgramsInstalled.CheckOnClick = True
        For counter As Integer = 0 To skname.Length - 1
            sk = rk.OpenSubKey(skname(counter))
            If sk.GetValue("DisplayName") <> "" Then
                clbProgramsInstalled.Items.Add(sk.GetValue("DisplayName") & ControlChars.CrLf)
            End If
        Next

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Determine if there are any items checked.
        If clbProgramsInstalled.CheckedItems.Count <> 0 Then
            ' If so, loop through all checked items and print results.
            Dim x As Integer
            Dim s As String = ""
            Dim t As String = ""
            For x = 0 To clbProgramsInstalled.CheckedItems.Count - 1
                s = s & Chr(155) & " " & clbProgramsInstalled.CheckedItems(x).ToString 'selection list with lead
                t = t & clbProgramsInstalled.CheckedItems(x).ToString 'slection list with no lead
            Next x
            MessageBox.Show("Are you sure you want to uninstall the following programs?" & ControlChars.CrLf & ControlChars.CrLf & s, "Confirm!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3)
            If Windows.Forms.DialogResult.OK Then
                'code to unistall selected apps
                Call Shell("msiexec.exe /uninstall", AppWinStyle.MaximizedFocus)
            End If

        Else
            'something else
        End If

    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub
End Class
 
Last edited:
Back
Top