6

I would like to close chromium web processs

enter image description here

without closing google chrome browser which are running

enter image description here

The code bellow close chromium browsers but also google chrome browsers, that I don't want to :

 var chromeAndChomiumProcesses = Process.GetProcessesByName("chrome");
 foreach (var chromeAndChomiumProcess in chromeAndChomiumProcesses)
 {
        chromeAndChomiumProcess.Kill();
 }

Do you know how to do this?

Pipo
  • 5,170
  • 7
  • 33
  • 66
  • 2
    IF you kill the process, the application will close. – Ryan Wilson May 01 '18 at 12:58
  • the tricky here is to kill chromium but no chrome @RyanWilson – Pipo May 01 '18 at 12:59
  • So you want to kill off any Google processes that are not the browser? – Ryan Wilson May 01 '18 at 13:01
  • I want to kill chromium web browsers https://www.chromium.org/getting-involved/download-chromium but no google chrome web browsers https://www.google.com/chrome/ – Pipo May 01 '18 at 13:04
  • seems like [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Why do you want to kill it, and does the process have anything distinguishing in the windows task manager .. like command line? – Slai May 01 '18 at 13:08

1 Answers1

3

This may work if you know the path to Chromium. Plus, You will have to compile the code as x64.

Process[] chrome = Process.GetProcessesByName("chrome");

foreach (var chromeProcess in chrome)
{
    string fullPath = chromeProcess.MainModule.FileName;
    string expectedPath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";

    if (fullPath.Equals(expectedPath))
    {
        chromeProcess.Kill();
    }
}

Also keep in mind this comparison needs to be case sensitive.

JimDel
  • 4,309
  • 11
  • 54
  • 99