How to end a process using C#

9.6k views Asked by At

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?

1

There are 1 answers

1
paul On BEST ANSWER

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

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