gb achilles
gb achilles

Reputation: 21

how can I kill a process by its window title name in c#

Guys how can I kill a process by its title name in c#. Say the title of Internet Explorer window is MSN | USA - Hotmail, Messenger...

I am making a small task manager like app that can kill an app with its title.

Upvotes: 0

Views: 3499

Answers (2)

Nicolai
Nicolai

Reputation: 2915

You can get all the IE processes, and then cycle through them, and check the windowtitle. Something like this:

System.Diagnostics.Process[] IEProcesses = System.Diagnostics.Process.GetProcessesByName("iexplore.exe");
        foreach (System.Diagnostics.Process CurrentProcess in IEProcesses)
        {
            if (CurrentProcess.MainWindowTitle.Contains("MSN | USA - Hotmail, Messenger"))
            {
                CurrentProcess.Kill();
            }
        }

Upvotes: 5

Related Questions