0

在 Windows 外壳中:

echo "foo bar" | find "foo"

成功(即errorlevel = 0)。但是,我想要一个在某些输入文本中找到特定单词时失败的脚本(即 errorlevel <> 0)。有任何想法吗?

4

1 回答 1

1

一点点诡计就可以模仿你想要的。只有前三行是必需的,其余的只是一个测试。

c:> echo "foo bar" | find "foo"
c:> if x%errorlevel%==x0 echo 1 | find "2"
c:> if not x%errorlevel%==x0 echo 1 | find "1" >nul 2>nul
c:> echo %errorlevel%
1
于 2009-03-06T08:04:35.550 回答