How we can kill the other running process in window with VB.NET 2.0 framework?
Asked
Active
Viewed 1.1k times
5 Answers
3
You and simply kill the process by kill() method.
Dim processList() As Process
processList = Process.GetProcessesByName(ListBox1.Items(ListBox1.SelectedIndex).ToString)
For Each proc As Process In processList
If MsgBox("Terminate " & proc.ProcessName & "?", MsgBoxStyle.YesNo, "Terminate?") = MsgBoxResult.Yes Then
Try
proc.Kill()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
Next

AKZap
- 1,181
- 6
- 17
- 31
1
You can use System.Diagnostics.Process.Kill to accomplish this. You can find the answer as well on How do I kill a process using Vb.NET or C#? (both C# as VB.NET answers).
Look at the MSDN Page: Process.Kill() for some more details.
Here is a code sample how to use it (took it parts from MSDN):
' First find the process(es) you want to kill, for example searching for the name
Dim notepadProcesses As Process() = Process.GetProcessesByName("notepad")
' Loop over the array to kill all the processes (using the Kill method)
Array.ForEach(notepadProcesses, Sub(p As Process) p.Kill())
1
You can get process name using Process.GetProcessesByName Method
and kill it using Process.Kill Method
.
Example:
Process[] processes = Process.GetProcessesByName("mspaint");
foreach (Process process in processes){
process.Kill();
}
MSDN Entries:
MSDN - Process.GetProcessesByName Method
Similar SO question:
How do I kill a process using Vb.NET or C#?
Hope this helps.
-1
1st create a a.bat file and store it into bin or in your project folder
In batch file write following line
tskill (your process name)
save it as .bat
in coding write following line
System.Diagnostics.Process.Start("Your bat file path")

Tanmay Nehete
- 2,138
- 4
- 31
- 42