windows batch-file:如果文件中存在字符串,如何设置errorlevel

时间:2021-03-25 23:30:41

In a windows batch-file, I want to 'EXIT 0' if the text 'no errors found' exists in a file 'output.txt'. And otherwise 'EXIT 1'.

在Windows批处理文件中,如果文件'output.txt'中存在'未发现错误',则我想要'EXIT 0'。否则'退出1'。

I'm sure this is easy, but I can't work it out.

我确信这很容易,但我无法解决。

1 个解决方案

#1


0  

The FIND command sets those errorlevels by default

FIND命令默认设置这些错误级别

@find "no errors found" "c:\the.file"
exit %errorlevel%

#1


0  

The FIND command sets those errorlevels by default

FIND命令默认设置这些错误级别

@find "no errors found" "c:\the.file"
exit %errorlevel%