Why does explorer restart automatically when I kill it with Process.Kill?
Posted
by
Thomas Levesque
on Super User
See other posts from Super User
or by Thomas Levesque
Published on 2012-11-27T11:13:06Z
Indexed on
2012/11/28
17:08 UTC
Read the original article
Hit count: 316
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...
© Super User or respective owner