Welcome!
Screen:
You will need:
1 combo box!
2 buttons!
a Brain
------------
Name button1 = Kill Process
Name button2 = Update List
---------
Add this code to imports,
Code:
Imports System.Diagnostics
---------
Add this code to form load!
Code:
Private S ub Form1_Load(B yVal sende r As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim proc As Process
ListBox1.Items.Clear()
For Each proc In Process.GetProcesses
ListBox1.Items.Add(proc.ProcessName)
Next
End Sub
This will add all processes to combo box!
----------
Add this code to button1
Code:
Priva Sub Button1_Click(ByVal sender As S ystem.Obje ct, ByVal e As System.Eve ntArgs) Handles Butto1.Click
Try
If ListBox1.SelectedItems.Count <= 0 Then
MessageBox.Show("Click on a process name to select it.", "No ProcessSelected(")
Return
End If
Dim p As System.Diagnostics.Process
For Each p In System.Diagnostics.Process.GetProcesses()
Dim arr() As String = _
ListBox1.SelectedItem.ToString().Split("-")
Dim sProcess As String = arr(0).Trim()
If p.ProcessName = sProcess Then
p.Kill()
MsgBox("Process Killed")
Dim proc As Process
ListBox1.Items.Clear()
For Each proc In Process.GetProcesses
ListBox1.Items.Add(proc.ProcessName)
Next
End If
Next
ListBox1.Update()
Catch ex As Exception
End Try
End Sub
End Sub
Kill selected process!
-------------------
Add this code to button2
Code:
Dim proc As Process
ListBox1.Items.Clear()
For Each proc In Process.GetProcesses
ListBox1.Items.Add(proc.ProcessName)
Next
MsgBox("Processes Updated", MsgBoxStyle.Exclamation)
Update processes!
---------
Full code(Don´t copy and paste, will not work MAOAHAHAHAHA!!)
Code:
Imports System.Diagnostics
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim proc As Process
ListBox1.Items.Clear()
For Each proc In Process.GetProcesses
ListBox1.Items.Add(proc.ProcessName)
Next
End Sub
Private Sub ListBox1SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If ListBox1.SelectedItems.Count <= 0 Then
MessageBox.Show("Click on a process name to select it.", "No ProcessSelected(")
Return
End If
Dim p As System.Diagnostics.Process
For Each p In System.Diagnostics.Process.GetProcesses()
Dim arr() As String = _
ListBox1.SelectedItem.ToString().Split("-")
Dim sProcess As String = arr(0).Trim()
If p.ProcessName = sProcess Then
p.Kill()
MsgBox("Process Killed")
Dim proc As Process
ListBox1.Items.Clear()
For Each proc In Process.GetProcesses
ListBox1.Items.Add(proc.ProcessName)
Next
End If
Next
ListBox1.Update()
Catch ex As Exception
End Try
End Sub
Private Button2_Click(BVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim proc As Process
ListBox1.Items.Clear()
For Each proc In Process.GetProcesses
ListBox1.Items.Add(proc.ProcessName)
Next
MsgBox("Processes Updated", MsgBoxStyle.Exclamation)
End Sub
Private Sub Button3Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
End Class