0

我一直在尝试在 Windows 7 sp1 中编写批处理脚本。在我启动批处理脚本后,我尝试在输入中键入一个选项,然后我得到“此时转到意外”,然后命令提示符关闭。请帮助我在个人项目中需要这个。

@echo off
:start
echo Is this the first time you ran this program on this computer 
set input=
set /p intput= "y/n"
if%input%==yes goto Yes
if%input%==no goto No

:No
pause
echo Okay skipping the installation process
cd Minecraft_Server
java -Xmx1024M -Xms1024M -jar minecraft_server*.jar
goto serverrestart

:serverrestart
echo Would you like to restart the server?
set input=
set /p intput= y or n
if%input%==y 
pause
goto restart
if%input%==n 
pause
goto norestart

:restart
echo To restart the server press any key.
java -Xmx1024M -Xms1024M -jar minecraft_server*.jar
goto serverrestart

:norestart
exit

:Yes 
pause
echo I will now install the Minecraft Serevr files, please make sure you 
echo have me in the "Parent Directory" of the Minecraft_Server folder
echo --If you don't know what a parent directory is GOOGLE it!--
pause
mkdir Minecraft_Server
move files.exe Minecraft_Server
cd Minecraft_Server
start files.exe
timeout /t 3
java -Xmx1024M -Xms1024M -jar minecraft_server*.jar
goto :serverrestart
4

1 回答 1

2

您在 set /p 行中拼错了输入,您应该使用引号。我使用 /i 使比较不区分大小写并缩短为所需的一个键。随心所欲。尝试这个:

@echo off
:start
echo Is this the first time you ran this program on this computer 
set "input="
set /p input= "y/n"
if /i "%input%"=="y" goto :Yes
if /i "%input%"=="n" goto :No
echo.Enter a valid choice
pause
goto :start
于 2013-09-26T21:58:52.237 回答