Question

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?

Was it helpful?

Solution

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();                
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top