0

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?

icktoofay
  • 126,289
  • 21
  • 250
  • 231
The Woo
  • 17,809
  • 26
  • 57
  • 71

1 Answers1

4

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();                
    }
}
shreyansp
  • 723
  • 1
  • 7
  • 16