How to kill a process?
I tried this and gives me an error

Dim RunningProcess As System.Diagnostics.Process = Process.GetProcessesByName("explorer.exe")(0)
RunningProcess.Kill()

and also Any code for enabling Task Manager, Regedit and Folder Option in VB 8?

Recommended Answers

All 2 Replies

Don't put .exe extension.

Dim p() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("calc")
 If p.Length = 1 Then
        p(0).Kill()
 End If
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim p() As System.Diagnostics.Process = Process.GetProcessesByName("cmd")
        If p.Length = 1 Then
            p(0).Kill()
        End If
    End Sub
End Class

I am trying to kill multiple cmd processes, the above code will only kill one of them, is there a way that I could kill all of them?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.