views:

1980

answers:

2

I'm trying to redirect all output (stdout + stderr) of a dos command to a single file:

C:\>dir 1> a.txt 2> a.txt
The process cannot access the file because it is being used by another process.

Is it possible, or should I just redirect to two separate files?

+6  A: 

You want:

dir > a.txt 2>&1
Anders Lindahl
A: 

I just chopped out the answer as @Anders just posted it, but...

From my windows help, I searched on redirection (url ms-its:C:\WINDOWS\Help\ntcmds.chm::/redirection.htm)

You may want to read about >> and | (pipe), too.

ericp