To kill a process in Batch you can use the snippets below.
If you dont know how to retrieve the PID you can use our other snippet List all Processes in Batch.
taskkill /PID 1292
if you want to force the taskkill you can use /F.
taskkill /F /PID 1292
if you want to taskkill the process by name you can use the follwoing snippet.
taskkill /im notepad++.exe
for more informations see the msdn TASKKILL
To kill a running process in C# and VB.NET you can use the following snippet.
public static void KillProcess(string name, bool waitForExit = true)
foreach (var process in Process.GetProcessesByName(name))
catch (Exception ex)
//handle the exception your way
Public Shared Sub KillProcess(name As String, Optional waitForExit As Boolean = True)
For Each process__1 As var In Process.GetProcessesByName(name)
If waitForExit Then
'handle the exception your way
Catch ex As Exception