Why does explorer restart automatically when I kill it with Process.Kill?
- by Thomas Levesque
If I kill explorer.exe like this:
private static void KillExplorer()
{
var processes = Process.GetProcessesByName("explorer");
Console.Write("Killing Explorer... ");
foreach (var process in processes)
{
process.Kill();
process.WaitForExit();
}
Console.WriteLine("Done");
}
It restarts immediately.
But if I use taskkill /F /IM explorer.exe, or kill it from the task manager, it doesn't restart.
Why is that? What's the difference? How can I close explorer.exe from code without restarting it? Sure, I could call taskkill from my code, but I was hoping for a cleaner solution...