【window】关于windows explorer.exe kill和恢复问题

最近要解决一个问题,就是explorer.exe。用了好多网友的建议,代码去实现一次性关闭explorer.exe,并且不会自动恢复的功能。

首先explorer.exe是管理window电脑任务栏和window桌面显示的功能。说白了就是不想看到开机后所有相关window界面。

我试了很多个方法,都是explorer.exe会自动恢复,查了相关资料,发现用代码实现window会自己进行轮询并恢复explorer.exe,但是我看到用任务管理器去关闭的时候就不会自动恢复。

所有就想着用cmd命令试试,果然运行

"taskkill /f /im explorer.exe"就不会出现自己恢复的情况。

               Process process = new Process();
               string strOutput = string.Empty;
                process.StartInfo.FileName = "cmd.exe";
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.RedirectStandardInput = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.StartInfo.CreateNoWindow = true;
                process.Start();
                process.StandardInput.WriteLine("taskkill /f /im explorer.exe"+ "&exit");
                process.StandardInput.AutoFlush = true;

即可以一劳永逸的关闭 explorer.exe。

当然kill之后需要恢复explorer.exe,当你的explorer.exe已经存在了,而你再次恢复explorer.exe就会直接弹出库文件夹。不符合需求,所以要判断一下explorer.exe是否存在,如果存在就不要继续去恢复explorer.exe,如果不存在就去恢复explorer.exe。

  if (Process.GetProcessesByName("explorer").Length <= 0)

 {
       System.Diagnostics.Process.Start("C:\\Windows\\explorer.exe");
}

mark 一下 ,不经常做这部分的内容,担心以后忘记。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值