Why is the last line not processed when I write the following in the bat file?

echo start
aaa | findstr bbb
echo end

I understand that the error "'aaa'is not recognized as an internal or external command, operable program or batch file" appears on the second line. I didn't understand whyecho endwas not executed.

If i know anyone, please professor.

  • Answer # 1

    I feel like a bug in CMD.EXE.
    If any of the commands that make up the pipe has an error that the command cannot be found, the remaining commands in the pipe will not be executed, but there may be a bug in the processing that prevents this command from being executed.


    echo start
    call aaa | findstr bbb
    (aaa) | findstr bbb
    echo end

  • Answer # 2

    How about this?

    @echo off
    echo start
    (aaa 2>&1) | findstr bbb
    echo end