Search code examples
c#processwindows-process

How to end a process using C#


I am attempting to end a process in C#, the current code I have is this:

foreach (var process in Process.GetProcessesByName("chromedriver.exe"))
{
    process.Kill();
}

In Task manager, under processes the Image Name:

chromedriver.exe *32

I am not ending the process... What is needed? or is this even possible?


Solution

  • '.exe' is not part of the process name, you just want:

    foreach (var process in Process.GetProcessesByName("chromedriver"))