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 on MSDN.
More Related Contents:
- How to 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?
- How can you find and replace text in a file using the Windows command-line environment?
- Adding a directory to the PATH environment variable in Windows
- How to check if a process is running via a batch script
- How to test if a file is a directory in a batch script?
- Escape angle brackets in a Windows command prompt
- $LastExitCode=0, but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError
- How can two text files be read in parallel by a batch file?
- Capture program stdout and stderr to separate variables
- “rd” exits with errorlevel set to 0 on error when deletion fails, etc
- Curl not recognized as an internal or external command, operable program or batch file
- Why %processor_architecture% always returns x86 instead of AMD64
- How do I call a Windows shell command using VB6?
- Why is the FOR /f loop in this batch script evaluating a blank line?
- PowerShell stripping double quotes from command line arguments
- Path prefixes \??\ and \\?\
- Windows console %DATE% Math