Findstr / errorlevel exit codes

I have a program that uses findstr , and when the string is found, errorlevel returns 0 , and when the string is not found, errorlevel returns 1 . Good thing I can handle this.

If the problem is that I cannot find the official documentation of what each errorlevel means for findstr . I need to know if anything else for findstr ever return errorlevel from 1 , or if it returns only 1 when the string is not found.

Links to the “official” documentation are preferable if they are, but any input would be appreciated.

Thanks in advance!

+7
cmd exit-code findstr
source share
2 answers

http://ss64.com/nt/findstr.html says:

 FINDSTR will set %ERRORLEVEL% as follows: 0 (False) a match is found in at least one line of at least one file. 1 (True) if a match is not found in any line of any file, (or if the file is not found at all). 2 Wrong syntax An invalid switch will only print an error message in error stream. 
+7
source share

It is documented in the Dos 6.22 Help for FIND team.

 │FIND exit codes │ │The following list shows each exit code and a brief description of its │meaning: │ │0 │ The search was completed successfully and at least one match was found. │ │1 │ The search was completed successfully, but no matches were found. │ │2 │ The search was not completed successfully. In this case, an error │ occurred during the search, and FIND cannot report whether any matches │ were found. │ │You can use the ERRORLEVEL parameter on the <If> command line in a batch │program to process exit codes returned by FIND. 
+2
source share

All Articles