Reputation: 5601
I would like to close chromium web processs
without closing google chrome browser which are running
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?
Upvotes: 6
Views: 1553
Reputation: 4359
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.
Upvotes: 3