Reputation: 18685
I'm writing an application in C#, and I'd like to close some other application—Internet Explorer, say. I've seen a lot of results for how to close the application you're building, but I want close an external program and I'm not sure where to start.
What part of the .NET framework would I use to do this?
Upvotes: 0
Views: 1334
Reputation: 783
You can kill the processes that match a specific name by using System.Diagnostics.Process;
:
foreach (Process clsProcess in Process.GetProcesses())
{
if (clsProcess.ProcessName.StartsWith("iexplore"))
{
clsProcess.Kill();
}
}
Upvotes: 4