I have a nt batch file which contains several commands. For each call, I have to redirect it to the same output/error file. Is there a way to set the output file and error file before starting execution so that even with no redirection, the output/error goes into respective file?
nt set output/error file
you can redirect the output to a file when you add ">filename" to your batch file call like
| Code: |
| xyz.bat >output.txt |
Here is a work around
This will enable logging the output and error of commands just by running the batch file (double click will do)
| Code: |
|
@echo off if "%1"=="exec" goto exec %~n0 exec %1 %2 %3 %4 %5 > %~dp0\%~n0.log 2>%~dp0\%~n0_error.log goto end :exec shift rem your commands here :end |
This will enable logging the output and error of commands just by running the batch file (double click will do)
