You want:
dir > a.txt 2>&1
The syntax 2>&1
will redirect 2
(stderr) to 1
(stdout). You can also hide messages by redirecting to NUL
. More explanation and examples are on the Microsoft documentation page Redirecting error messages from Command Prompt: STDERR/STDOUT.
More Related Contents:
- Redirect Windows cmd stdout and stderr to a single file
- Single line with multiple commands using Windows batch file
- How do I run two commands in one line in Windows CMD?
- Batch command date and time in file name
- How do I get the application exit code from a Windows command line?
- How can I create an empty file at the command line in Windows?
- Stop and Start a service via batch or cmd file?
- Create an empty file on the commandline in windows (like the linux touch command)
- Windows shell command to get the full path to the current directory?
- Create a new cmd.exe window from within another cmd.exe prompt
- How do I minimize the command prompt from my bat file
- Why doesn’t my stderr redirection end after command finishes? And how do I fix it?
- Windows command interpreter: how to obtain exit code of first piped command
- How to detect if CMD is running as Administrator/has elevated privileges?
- Is there an equivalent of ‘which’ on the Windows command line?
- Batch file: Find if substring is in string (not in a file)
- Batch character escaping
- Find out if file is older than 4 hours in Batch file
- ‘chcp’ is not recognized as an internal or external command, operable program or batch file. on a Windows PC
- How to display japanese Kanji inside a cmd window under windows?
- Using another language (code page) in a batch file made for others
- How can I debug a .BAT script?
- Start multiple tasks in parallel and wait for them in windows?
- Command-line tool for finding out who is locking a file
- How do I add to the Windows PATH variable using setx? Having weird problems
- How to write a multiline command?
- Run a Command Prompt command from Desktop Shortcut
- Ping with timestamp on Windows CLI
- How to delete empty folders using windows command prompt?
- Are there any XSLT processing command line tools? [closed]