I want to exit from the for loop after getting the first string. How can I do that? Should I use for loop or something else?
for /F "delims=" %%c in ('dumpbin "%%i" /headers ^| findstr "(x86)"') do set Result3=%%c
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use GOTO to exit a FOR loop prematurely. Both FOR and FOR /F are terminated immediately when GOTO is executed.
The FOR /L will sort of exit immediately upon GOTO in that the contents of the DO clause will no longer be executed. But the FOR /L will silently continue to count until it reaches its end condition.
If your intent is to immediately leave not only the FOR loop but also exit out of a subroutine or batch script, then it is more efficient to use EXIT /B instead of GOTO :LABEL.