为什么 IF/ELSE 命令在我的批处理代码中不起作用?
Why are the IF/ELSE commands not working in my batch code?
正在尝试让程序运行多人合作模式,但我的批处理脚本不工作,我想我已经搞砸了。试着找一个朋友帮忙,结果是这样,但根本行不通,我失去了所有的进步。谁能告诉我这里有什么问题 and/or 更正一下?
:hostmpcoop
set /p files="(Optional) Enter stuff to run spaced by -file : "
set /p playercount="Enter number of desired players: "
if "%files%"=="" (
echo No files entered.
if not "%playercount%" == "" (
echo Running vanilla MP
thing.exe -host %playercount%
)else(
echo You need to specify a playercount!
goto hostmpcoop
)
)
if not "%files%"=="" (
if not "%playercount%"=="" (
thing.exe -host %playercount% -file %files%
)else(
echo You need to specify a playercount!
goto hostmpcoop
)
)
if "%files%"==""(
if "%playercount%"=="" (
echo "Enter a player count!"
goto hostmpcoop
)
)
goto home
当使用 else 和 if 时,括号两边需要空格:
:hostmpcoop
set /p files="(Optional) Enter stuff to run spaced by -file : "
set /p playercount="Enter number of desired players: "
if "%files%"=="" (
echo No files entered.
if not "%playercount%" == "" (
echo Running vanilla MP
thing.exe -host %playercount%
) else (
echo You need to specify a playercount!
goto hostmpcoop
)
)
if not "%files%"=="" (
if not "%playercount%"=="" (
thing.exe -host %playercount% -file %files%
) else (
echo You need to specify a playercount!
goto hostmpcoop
)
)
if "%files%"=="" (
if "%playercount%"=="" (
echo "Enter a player count!"
goto hostmpcoop
)
)
回到家
正在尝试让程序运行多人合作模式,但我的批处理脚本不工作,我想我已经搞砸了。试着找一个朋友帮忙,结果是这样,但根本行不通,我失去了所有的进步。谁能告诉我这里有什么问题 and/or 更正一下?
:hostmpcoop
set /p files="(Optional) Enter stuff to run spaced by -file : "
set /p playercount="Enter number of desired players: "
if "%files%"=="" (
echo No files entered.
if not "%playercount%" == "" (
echo Running vanilla MP
thing.exe -host %playercount%
)else(
echo You need to specify a playercount!
goto hostmpcoop
)
)
if not "%files%"=="" (
if not "%playercount%"=="" (
thing.exe -host %playercount% -file %files%
)else(
echo You need to specify a playercount!
goto hostmpcoop
)
)
if "%files%"==""(
if "%playercount%"=="" (
echo "Enter a player count!"
goto hostmpcoop
)
)
goto home
当使用 else 和 if 时,括号两边需要空格:
:hostmpcoop
set /p files="(Optional) Enter stuff to run spaced by -file : "
set /p playercount="Enter number of desired players: "
if "%files%"=="" (
echo No files entered.
if not "%playercount%" == "" (
echo Running vanilla MP
thing.exe -host %playercount%
) else (
echo You need to specify a playercount!
goto hostmpcoop
)
)
if not "%files%"=="" (
if not "%playercount%"=="" (
thing.exe -host %playercount% -file %files%
) else (
echo You need to specify a playercount!
goto hostmpcoop
)
)
if "%files%"=="" (
if "%playercount%"=="" (
echo "Enter a player count!"
goto hostmpcoop
)
)
回到家