@echo off
:start
cls
color e
echo YOU HAVE WON $1,000,000! WHAT WILL YOU DO?
echo.
echo =================
echo -Take it (1)
echo -Leave it (2)
echo -Double it (3)
echo =================
echo.
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
set /p INPUT=Please specify your answer:
If /i "%INPUT%" == "1" goto 1
If /i "%INPUT%" == "2" goto 2
If /i "%INPUT%" == "3" goto 3
我上面有这个代码,并且有一个非常讨厌的事情,我无法弄清楚。所以你可以看到我反复改变颜色,但你可以看到它阻碍了下一个命令。在选择答案之前,有没有办法让它像在后台一样? (1,2或3)。
答案 0 :(得分:2)
将start /B
与辅助脚本一起使用可以解决问题。
当aux脚本发现存在临时文件时退出。 Lame但是很有效。
我的模型主程序(称之为main.bat
)
@echo off
:start
cls
color e
echo YOU HAVE WON $1,000,000! WHAT WILL YOU DO?
echo.
echo =================
echo -Take it (1)
echo -Leave it (2)
echo -Double it (3)
echo =================
echo.
start /B %~dp0\color_cycling.bat
:err
set /p INPUT=Please specify your answer:
If /i "%INPUT%" == "1" goto 1
If /i "%INPUT%" == "2" goto 2
If /i "%INPUT%" == "3" goto 3
goto err
:1
echo.> %TEMP%\stopcol
echo take it
set /p SURE=are you sure?
pause
:2
echo.> %TEMP%\stopcol
echo leave it
pause
我的color_cycling.bat
例程
@echo off
del %TEMP%\stopcol 2>NUL >NUL
:lab
for %%i in (a b e) do (
timeout /t 1 >nul 2>&1
color %%i
if exist %TEMP%\stopcol exit
)
goto lab
确实从1977年开始效果很好!