假设以下批处理文件。
set variable1=this is variable1
set variable2=is
set variable3=test
if variable1 contains variable2 (
echo YES
) else (
echo NO
)
if variable1 contains variable3 (
echo YES
) else (
echo NO
)
我希望输出结果为“是”后面跟着一个“不是”。
/?
、变量1=on
和变量1=off
都会失败。考虑使用echo foobar %variable1%|find "%variable2%" >nul
,但对于变量2=foobar也会失败。 - GKFX