2015-08-04 7 views
7

Ich habe ein Programm, das findstr verwendet, und wenn die Zeichenfolge gefunden wird, die errorlevel kehrt 0 und wenn die Zeichenfolge nicht gefunden wird die errorlevel kehrt 1. Ok, damit kann ich umgehen.findstr Exit-Codes/Errorlevel

Wo das Problem liegt, kann ich keine offizielle Dokumentation darüber finden, was jeder errorlevel bedeutet für findstr. Ich muss wissen, ob etwas anderes für findstr jemals eine errorlevel von 1 zurückgeben kann, oder wenn es nur 1 zurückgibt, wenn die Zeichenfolge nicht gefunden wird.

Links zu 'offiziellen' Dokumentationen werden bevorzugt, wenn es welche gibt, aber jede Eingabe würde sehr geschätzt werden.

Vielen Dank im Voraus!

Antwort

7

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

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. 
+0

Vielen Dank, genau das, was ich gesucht habe! –

2

Es ist in der Dos 6.22 Hilfe für FIND Befehl dokumentiert.

│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. 
+0

Gilt dies auch auf 'findstr '? –

+0

Ja. Ich suchte seit 12 Jahren nach einer neueren Referenz. Ich habe DOS 6.22 und OS/2 Warp 4 (es sagt _It gibt 0 für normale Fertigstellung_ zurück). – bill

Verwandte Themen