杀死资源管理器进程 [英] Kill Explorer process
问题描述
很奇怪,但是也许我用不正确的方式处理它-我需要非常简单地检查explorer.exe是否正在运行,如果是,则将其杀死.但是,按照我目前的实现方式,explorer.exe会在我杀死它后重新启动.
Strange, but perhaps I am handling it the incorrect way - I need to quite simply check if explorer.exe is running, and if so kill it. However, the way I am currently achieving this, explorer.exe simply restarts after I kill it.
通过批处理进行正常的taskkill可以很好地工作,C#是否有其他不同之处?
Normal taskkill through batch works fine though, does C# do something different?
private void Form1_Load(object sender, EventArgs e)
{
Process[] prcChecker = Process.GetProcessesByName("explorer");
if (prcChecker.Length > 0)
{
MessageBox.Show("Explorer running");
foreach (Process p in prcChecker)
{
p.Kill();
}
}
else
{
MessageBox.Show("Explorer is not running");
}
}
推荐答案
这是因为Windows会在explorer.exe
死掉时负责重新启动它.
That's because Windows takes care of restarting explorer.exe
if it happens to die.
可以延迟此行为(例如,tortoisegit的设置会这样做),但不建议这样做-用户会很生气.
It is possible to delay this behavior (the setup of tortoisegit does this, for example), but it's not recommended - users are going to be pissed.
这篇关于杀死资源管理器进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!