Pergunta

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?

Foi útil?

Solução

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();                
    }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top