Thursday, January 14, 2016

How to Kill all the Open Browser

We can use using System.Diagnostics namespace using C#.


public static void CloseAllBrowsers()
        {
            List<string> browserList = new List<string>() { "iexplore", "chrome", "firefox" };
            Process[] process = Process.GetProcesses().Where(x => browserList.Contains(x.ProcessName))
                .ToArray();
                

            foreach (Process proc in process)
            {
                proc.Kill();
                while (!proc.HasExited) { }
            }
        }

No comments:

Post a Comment