bat中如何用if判断输入设定为2个选项,如果输入非这2个选项.怎么让他执行第3条命令
还是不明白,我是2选则.如果输入非1 2
执行第3条命令
@echo off
:loop
1.打开C盘
2.打开D盘
set /p in=请选择(1/2):
if "%in%"=="1" start c:
if "%in%"=="2" start d:
start e:
pause
前面判断两个选项,第三条命令直接跟在后面就行了..前面判断不成功自动运行到第三条了..
:loop
1.打开C盘
2.打开D盘
set /p in=请选择(1/2):
if "%in%"=="1" start c:
if "%in%"=="2" start d:
start e:
pause
前面判断两个选项,第三条命令直接跟在后面就行了..前面判断不成功自动运行到第三条了..
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2016-05-02
第2个回答 2019-12-06
@echo off
for %%i in ( 1 2 ) do (
set /p input="请输入数字1或2选择:"
if "%input%"=="%%i" (
goto select%%i
) else (
goto selet3
)
)
exit
:select1
command1
:select2
command2
:select3
command3
for %%i in ( 1 2 ) do (
set /p input="请输入数字1或2选择:"
if "%input%"=="%%i" (
goto select%%i
) else (
goto selet3
)
)
exit
:select1
command1
:select2
command2
:select3
command3
第3个回答 2019-03-01