I don't know anymore. As I just did not try to kill the chrome.exe process via C #. Nothing happens. Maybe someone can tell what is wrong with my "code".

First I create an array of all processes, then I go around this array and if the process name matches the required string, I kill it.

Process[] listprosecc = Process.GetProcesses(); foreach (Process oneproc in listprosecc) { string ProsessName = oneproc.ProcessName; ProsessName = ProsessName.ToLower(); if (ProsessName.Equals("chrome.exe")) { oneproc.Kill(); MessageBox.Show("Я дошел!!!"); } } 
  • In if comes? - Ev_Hyper
  • one
    var pr = prss.Select(p => p.ProcessName.Contains("chrome")).Count(); I get 141 of such a process :) - Bulson
  • @Ev_Hyper. That is the point, no. But the process is 100% named chrome.exe - batya
  • @batya: And you try "chrome" , without .exe . - VladD

2 answers 2

Maybe so try?

 try { foreach (Process proc in Process.GetProcessesByName("chrome")) { proc.Kill(); } } catch(Exception ex) { MessageBox.Show(ex.Message); } 

    try using this method.

     foreach (var process in Process.GetProcessesByName("ваш процесс")) { process.Kill(); } 

    Do not put .exe in the process name.

    • That's just what he dope. But thanks anyway. - batya
    • 2
      @batya is not entirely fair. Daniel Protopopov gave you a similar answer even earlier, but for some reason you didn’t protect him. - Bulson
    • @Bulson you are right ... but, not I chose) - Insider
    • @Insider and I have no complaints to you, but turned to batya - Bulson
    • @Insider Everything. I've changed. - batya