I am working on a c# winforms application. I am trying to close a running process by its process ID.
try
{
//Find process & Kill
foreach (Process Proc in (from p in Process.GetProcesses()
where p.ProcessName == "taskmgr" || p.ProcessName == "explorer"
select p))
{
Microsoft.VisualBasic.Interaction.Shell("TASKKILL /F /IM " + Proc.ProcessName + ".exe");
}
}
catch (Exception ex)
{
ErrorLogging.WriteErrorLog(ex);
}
return null;
This code is not working on windows 2003 SP 2. I have googled and found that 2003 does not have the taskkill command. What would be a substitute for that?