批处理例程避免退出其他命令
Batch routine avoid exit from other commands
我有一个批处理程序,可以执行来自不同库的命令。问题是这些库在执行时会自动完成控制台。
似乎 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
主要思想是是否有任何方法或参数可以避免在不编辑适当的库的情况下关闭带有此类库的控制台。
在方法生效前使用命令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
我有一个批处理程序,可以执行来自不同库的命令。问题是这些库在执行时会自动完成控制台。
似乎 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
主要思想是是否有任何方法或参数可以避免在不编辑适当的库的情况下关闭带有此类库的控制台。
在方法生效前使用命令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