bat文件如果用java的Runtime.getRuntime().exec("cmd.exe /c cd /d \"D\\:xxxx\" & call update.bat \" myprotocol:参数&参数&参数\" ")
用&隔开多指令
如果单只有 update.bat运行的话 经过main方法测试 在update.bat中设置延时,main进程结束bat会被中断
解决:
在xxx.bat 之前加call 或者 start ,两者区别在于start会弹出黑色弹框 ,并且有点小问题exit指令关闭不掉(暂时未知)
call可以在不随进程结束,后台默默执行
update.bat:
:query
if exist mpm-client-temp.exe(
@taskkill /F /IM mpm-client.exe
@ping -n 3 127.0.0.1>nul
@delete /f /s /q xxxx.exe
@mpm-client.exe %1
@exit
)
@ping -n 3 127.0.0.1>nul
goto query
https://blog.csdn.net/sinat_34820292/article/details/81513611
这个讲的易懂一些,可以看看