Run batch script showing output & recording output to a file

scriptingwindows-server-2008-r2

I know cmd > file.txt to record an output of a command to a file in Windows!.

Does anybody know how to run a batch script recording the output to a file AND also showing the output on the command prompt as well when executed?

Best Answer

You'll need a Windows-based implementation of tee to do this. Here are some options:

If you don't require output in situ, you can "cheat" by piping the commands, but this is not nearly as useful as following stdout in real-time.

cmd >file.txt | type file.txt