所有我都在尝试查看名为%scamble%
"Yes"
"Y"
,"No"
"N"
,而无需使用大量的if语句。再次,我不知道我在做什么...我学到了这一切。所以把我当作一个好奇的菜鸟。 类似
echo This is a ONE TIME prompt (for this session ONLY).
set /p scramble=Y/N: || set scramble=Y
for /f "text=," %%a in (%scamble%) do (
set string = %%a
if "!string:%substring%=!"=="!string!" (
echo Found!
)
)
我必须重申,我不知道自己在做什么,但是我认为我可能会有些了解。所以我问你,互联网的人,请帮忙!谢谢
the以前的问题答案:
if not x%str1:bcd=%==x%str1% echo It contains bcd
除非召集:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
set str1=abcdefg
if "%~1" == "" Call :CheckString
pause
exit
:CheckString
if not x%str1:bcd=%==x%str1% echo It contains bcd
exit /b
您仍然需要其中4个,所以没有太大的区别,否则可以方便。
If "%%a" == "Y" (echo Is Y) ELSE (echo Not Y)
theles还与琴弦相呼应:
以个人的方式我只会使用一个选择CMD:
:: Numbers:
echo Press 1 for blah
echo Press 2 for blah
choice /n /c 12
if "%errorlevel%" == "1" (
echo Do whatever for 1...
)
if "%errorlevel%" == "2" (
echo Do whatever for 2...
)
pause
exit
:: Even better Using Numbers:
echo Press 1 for blah
echo Press 2 for blah
choice /n /c 12
:: Loop from 1, up by 1 at a time, upto 5..
For /L %%i in (1,1,5) Do (
If "%errorlevel%" EQU "%%i" (echo Number %%i: This was Selected by User)
)
pause
exit
:: Letters:
echo Press 1 for blah
echo Press 2 for blah
choice /n /c 12
if "%errorlevel%" == "1" (
echo Do whatever for 1...
)
if "%errorlevel%" == "2" (
echo Do whatever for 2...
)
pause
exit