我有一个批处理程序,它执行来自不同库的命令。问题是这些库在执行时会自动完成控制台。
似乎pause
命令不起作用,因为可能那些库将拥有它们自己的exit
命令。我尝试使用我在谷歌上找到的命令cmd /k
,但它也不起作用。
:start
cls
echo.
echo 1) Desc 1
echo 2) Desc 2
set /p option=Enter an option:
IF "%option%"=="1" (
rem this is an example of library that exit console after being executed
pm2 start ecosystem.config.js --env development
)
IF "%option%"=="2" (
pm2 monit
)
pause
goto start
主要的想法是,如果有任何方法或参数,以避免使用这些类型的库关闭控制台而不编辑适当的库。
在方法工作之前使用命令call
:
:start
cls
echo.
echo 1) Desc 1
echo 2) Desc 2
set /p option=Enter an option:
IF "%option%"=="1" (
rem this is an example of library that exit console after being executed
call pm2 start ecosystem.config.js --env development
)
IF "%option%"=="2" (
call pm2 monit
)
pause
goto start