批处理例程避免从其他命令退出

时间:2019-03-20 09:31:07

标签: batch-file pm2

我有一个批处理程序,该程序执行来自不同库的命令。问题在于这些库在执行时会自动完成控制台。

pause命令似乎不起作用,因为这些库可能拥有它们自己的exit命令。我尝试使用在Google上找到的命令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

主要思想是,是否有任何方法或参数可以避免在不编辑适当库的情况下使用此类库关闭控制台。

1 个答案:

答案 0 :(得分:0)

在方法生效之前使用命令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
相关问题