Is there a simple way to log everything that appears on the command line on Windows?
I have a batch file that is running some things, but everything flies by so fast I cannot see if any errors have occurred.
In the command, change "YOUR-COMMAND" with your command and "c:\PATH\TO\FOLDER\OUTPUT. txt" with the path and file name to store the output. In the command, change "YOUR-COMMAND" with your command and "c:\PATH\TO\FOLDER\OUTPUT. txt" with the path and filename to store and view the output.
Any command that has a command window output (no matter how big or small) can be appended with > filename. txt and the output will be saved to the specified text file.
Command echoing is on by default. Specifies the text to display on the screen.
You can redirect the results to a file:
C:\> myBatch.bat > myBatch.log
The above will redirect standard output to a file called myBatch.log
.
If you need to redirect standard error to this file as well, you can append 2>&1
to the command:
C:\> myBatch.bat > myBatch.log 2>&1
Note that the single >
will overwrite a file and start from scratch and >>
will append the captured output to the end of the file. You should be careful when using this syntax in a set of consecutive commands to use >
on the first call to start a file, and then >>
on all subsequent calls to add to the end of the new file.
For example, a simple bat file,
@echo off
echo start > test.log
date /t >> test.log
time /t >> test.log
echo done >> test.log
will generate a file named test.log
filled with the following content:
start
Tue 09/22/2009
03:10 PM
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With