![在批处理中的多个提示中运行多个命令](https://linux22.com/image/1338662/%E5%9C%A8%E6%89%B9%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E5%A4%9A%E4%B8%AA%E6%8F%90%E7%A4%BA%E4%B8%AD%E8%BF%90%E8%A1%8C%E5%A4%9A%E4%B8%AA%E5%91%BD%E4%BB%A4.png)
我目前有三个批处理文件,并试图将功能合并为一个。
run.bat
--------
start "" /min cmd /k first.bat
start "" /min cmd /k second.bat
first.bat
--------
call C:\Users\jh\python_environment\Scripts\activate.bat
coilmq
second.bat
--------
call C:\Users\jh\python_environment\Scripts\activate.bat
python "C:\Users\jh\run\main.py"
因此我执行 run.bat 来获得我想要的东西。这会打开两个命令窗口,每个窗口运行相应的命令,然后它们被最小化。我如何将所有此功能合并到一个 bat 脚本中?
答案1
run.bat
if not "%~1"=="" goto %1
start "" /min cmd /k "%~0" first
start "" /min cmd /k "%~0" second
goto :EOF
:first
call C:\Users\jh\python_environment\Scripts\activate.bat
coilmq
goto :EOF
:second
call C:\Users\jh\python_environment\Scripts\activate.bat
python "C:\Users\jh\run\main.py"
goto :EOF