Windows Doc命令循环检测进程是否存在,不存在则重启等

命令使用方式,直接新建文本,格式是.bat。然后将以下代码贴入文本,双击运行即可。

PS:使用时,记得将括号和括号的文字内容删除

@echo off & title 监测进程By Garcia
:start
cls
tasklist|find /i "chrome.exe" (进程的exe文件名)
if %errorlevel%==0 goto runff
if %errorlevel%==1 echo 没有找到该进程正在准备重启中...&goto open
:runff
ping 127.0.0.1 -n 5 (5秒执行一次)
echo 进程正常运行中!&goto start

:open
start /d "C:\Program Files\Google\Chrome\Application\" chrome.exe  (需要运行的exe路径)
goto start

猜你喜欢

转载自blog.csdn.net/Qensq/article/details/120344068