我一直在尝试在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
答案 0 :(得分: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