Windows command interpreter: how to obtain exit code of first piped command
In the example provided below, I execute nmake and then redirect STDOUT/STDERR to tee, which then sends it to the screen, and also to a log file. The problem is that I'm trying to capture the exit code for nmake and not tee. What I need is the exit code from nmake, and not tee. nmake | tee output.txt You might think you could do something like the following, but it won't work. (nmake & call set myError=%%errorlevel%%) | tee output.txt The problem lies in the mechanism by which Windows pipes work. Each side of the pipe is executed in it's own CMD shell. So any environment variable you set there