Board logo

标题: [系统相关] 重启桌面的批处理为何不行呢? [打印本页]

作者: sl790829ok    时间: 2018-5-25 14:00     标题: 重启桌面的批处理为何不行呢?

@echo off
taskkill /im explorer.exe /f /t
cls
explorer.exe
cls
exit

可以停掉桌面进程但是无法重建桌面进程。

如果改为taskkill /im explorer.exe /f
可以重建桌面进程但是不能自己关闭掉cmd窗口。
而且有时候会生成多个explorer.exe进程,感觉好像杀的不彻底会。
作者: hlzj88    时间: 2018-5-25 14:14

start  explorer.exe
作者: CrLf    时间: 2018-5-25 15:33

你的 cmd.exe 是桌面的子进程,加 /T 开关把 cmd 也杀了,当然不会执行后面的命令
作者: yhcfsr    时间: 2018-5-25 15:59

你的 cmd.exe 是桌面的子进程,加 /T 开关把 cmd 也杀了,当然不会执行后面的命令
CrLf 发表于 2018-5-25 15:33



解释的很好啊。所以,综合二三楼,得出以下:
  1. @echo off
  2. taskkill /f /im "explorer.exe"
  3. start explorer.exe
复制代码

作者: 见与不见    时间: 2018-5-25 17:24

回复 1# sl790829ok


@echo off
taskkill /f /im ex*>nul 2>nul
ping 127.0.1 /n 2 >nul
start explorer
pause
作者: /zhqsystem/zhq    时间: 2018-5-25 17:48

试试这个,有延迟错误
Wmic Process Where Name='explorer.exe' call Terminate




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2