tags:

views:

13

answers:

1

Okay, here's a toughie-- I'm capturing the output of cmd.exe just fine, reading from the pipe, yadda yadda yadda, but then a line in the cmd.exe batch file has the audacity to do:

dir err.txt >zz

.. that is, it's redirecting the output of the dir command, which is an internal command inside cmd.exe.

Problem is, this breaks my capturing of output! I can't get anything from cmd.exe after that point.

Apparently to redirect standard output, it closes it, or somehow breaks it, and makes a new stdout to redirect the output. And it never restores the old stdout handle.

Any ideas of how to track this output?

A: 

you should call dir err.txt in a separate process. try "call dir err.txt >zz".

adymitruk
`call` won't use a separate process. You'd need `cmd /c "dir err.txt>zz"` in that case.
Joey