On Windows when running a batch script I want to record the output of I run:

myprogram.bat 1> mylog.log 2>&1

Which is great - but I have to run a separate tail process to read the output in another window. What I want is to be able to record it to a file and see it in the window all at once.

Now on a mac I can do this with:

./a.out 2>&1 | tee output

My question is: How do I pipe stdout and std error to a file and back to stdout on Windows?


I do not think that is possible. You can either use a 3rd-party tool, such as WinTee:

myprogram.bat | wintee "mylog.log"

or switch to PowerShell and use Tee-Object cmdlet:

.\myprogram.bat | Tee-Object "mylog.log"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.