等待程序结束后, 自动启动程序的批处理

基本用于程序自身重启用, 很简单的代码

:start
(wmic process where creationclassname="win32_process" get executablepath) | (find /i "等待关闭的程序,包含路径")
if %errorlevel% equ 0 (goto start)
start "" "要启动的程序,包含路径"

 

2019-11-06 附加一个新的方案, 通过PID判断:

:start
tasklist /fi "pid eq 程序PID" | findstr /i "程序名(不含路径)" >nul &&goto start
::如果等待运行结束用下面的, 不等待用start "" "程序"启动
"要运行的程序(含路径)" "启动参数"
::执行完后删除自己
attrib -h -s -r -a %0
del %0

 

posted on 2017-10-13 15:55  黑暗煎饼果子  阅读(1384)  评论(0编辑  收藏  举报