How can I redirect output to a text file and the console (cmd) window at the same time?

link|improve this question

50% accept rate
feedback

2 Answers

up vote 2 down vote accepted

Powershell 2.0 comes with the Tee-Object cmdlet which does exactly that. If you're using Windows 7, it comes with Powershell 2.0 installed. If you're using an older version of Windows, Powershell 2.0 is available for download.

The benefit of Powershell is that it can run the commands that cmd can as well.

Example:

dir | Tee-Object -file c:\output\dir.txt
link|improve this answer
feedback

There's a good answer for an identical question on StackOverflow

In summary, find a Win32 port of the Unix tee command.

link|improve this answer
Hehe. I posted here as I thought would moved if I posted on StackOverflow. I'll mark this as the answer if I don't find an alternative :) – Thomas Bratt Feb 17 '10 at 14:58
feedback

Your Answer

 
or
required, but never shown

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