Home

Published

- 1 min read

c# kill process access denied

img of c# kill process access denied

The solution for this is noted below

c# kill process access denied

Solution

   string processName = "ProcessName.exe";
Process[] processes = Process.GetProcessesByName(processName);
foreach (Process process in processes)
{
    try
    {
        Process.Start("taskkill", $"/pid {process.Id} /f");
    }
    catch (Exception ex)
    {
        // Handle the exception
    }
}

Try other methods by searching on the site. That is if this doesn’t work