You can use FINDSTR to search for multiple entries at the same time. Use it like this:
FINDSTR "term1 term2 term3 ..."
The result will be a success if at least one term has been found. Use the /I
switch to make the search case insensitive, if necessary:
FINDSTR /I "term1 term2 term3 ..."
FINDSTR
searches stdin
by default. Redirect the input to your .inf
file to make it search the file:
FINDSTR /I "term1 term2 term3 ..." <file.inf
Alternatively, you could put the file name as another parameter:
FINDSTR /I "term1 term2 term3 ..." file.inf
The output will be slightly different in the two cases, but I understand you don't actually need the output but the result of the search, i.e. whether it succeeded or failed.
To check the result, you can use explicit ERRORLEVEL
test, like this:
FINDSTR /I "term1 term2 term3 ..." file.inf
IF NOT ERRORLEVEL 1 yourprogram.exe
An alternative syntax to that would be to use the ERRORLEVEL
system variable, which is probably more straightforward than the former:
IF %ERRORLEVEL% == 0 yourprogram.exe
Another way to do the same is to use the &&
operator. This method is not entirely identical to the ERRORLEVEL
test, but with FINDSTR
both ERRORLEVEL
test and &&
work identically, and in this situation the &&
method has the advantage of being more concise:
FINDSTR /I "term1 term2 term3 ..." file.inf && yourprogram.exe
This is almost it. One final note is, since you may not be actually interested in the output of FINDSTR
, you might as well want to suppress it by redirecting it to NUL
, like this:
FINDSTR /I "term1 term2 term3 ..." file.inf >NUL && yourprogram.exe