Batch file 为什么我的批处理程序一直崩溃?

Batch file 为什么我的批处理程序一直崩溃?,batch-file,Batch File,我做了一个(到目前为止是571行)冒险游戏,但每当我在这个字符串中选择“3”时,它就会崩溃。就像,它会立即关闭窗口。我唯一的想法是,这可能是如何设置选项1,但任何帮助都将不胜感激 :stayinbed cls echo You slowly get out of bed, the monster watches you. echo. echo 1) Make a run for it. echo 2) Begin to teach it how to speak, be nice to it.

我做了一个(到目前为止是571行)冒险游戏,但每当我在这个字符串中选择“3”时,它就会崩溃。就像,它会立即关闭窗口。我唯一的想法是,这可能是如何设置选项1,但任何帮助都将不胜感激

:stayinbed
cls
echo You slowly get out of bed, the monster watches you.
echo.
echo 1) Make a run for it.
echo 2) Begin to teach it how to speak, be nice to it.
echo 3) Get a kitchen knife.
echo.
:loop11
set /p Choice=Choose Now: 
if "%Choice%"=="1" 
cls
gotorun4life3
if "%Choice%"=="2" goto justbenice
if "%Choice%"=="3" goto kitchen
goto loop11

:justbenice
cls
echo You spend the next couple years of your life teaching the creature about life.
echo He is like a child to you, a very disgusting child that is not allowed in public.
echo.
pause
cls
echo You spend decades with him, researching all fields of science.
echo But alas, all good things come to an end.
echo Eventually you contract cancer and die, the monster at your bedside.
pause
goto end1

:kitchen
cls
echo You begin to slowly walk towards your cabinet.
timeout /t 2 /nobreak >nul
echo It watches you, but you keep walking towards the cabinet.
timeout /t 2 /nobreak >nul
echo You arrive at the cabinet and grab a knife.
echo.
echo 1) Screw it, just run.
echo 2) Kill the abomination.
echo.
:loop12
set /p Choice=Choose Now: 
if "%Choice%"=="1" 
cls
goto run4life3
if "%Choice%"=="2" goto killit
goto loop12


:killit
cls
echo You grasp the knife in your hand and look right at the creature.
timeout /t 1 /nobreak >nul
echo You run towards it.
timeout /t 1 /nobreak >nul
echo You stab it in the back of the head.
call :colorEcho 0a "RAAAAUUUGGGHHH"
echo.
echo It falls flat on the ground with a thud.
goto end1

问题在于:

if "%Choice%"=="1" 
cls
gotorun4life3
应该是:

if "%Choice%"=="1" cls & goto run4life3


当它到达行
gotorun4life3
时,它会崩溃,因为它无法解析此命令。

因为你在一行上有
如果“%Choice%”==“1”
。不要这样做。从已经打开的命令提示符启动程序。然后窗口将无法关闭。您也可以将
cls
goto run4life3
放在代码块中。@SomethingDark这是什么意思?像这样。(我会把它贴在评论中,但评论不能有新行…)
if "%Choice%"=="1" (
    cls
    goto run4life3
)