I’m trying to redirect all output (stdout + stderr) of a Windows 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?
You want:
The syntax
2>&1will redirect2(stderr) to1(stdout). You can also hide messages by redirecting toNUL. More explanation and examples are on the Microsoft documentation page Redirecting error messages from Command Prompt: STDERR/STDOUT.