Is there a way to redirect the output of stderr from the command line running at the Windows command line?
I have a program for which I want to automate runs as it takes a while to complete. For some reason, it outputs everything to stderr instead of stdout and I would like to check its progress, so I need to redirect the output of stderr in the run command.
I've tried this:
start "My_Program" "C:\Users\Me\my_program.exe" --some --presets --for
--my_program.exe --output "C:\Users\Me\output_file_for_my_program"
"C:\Users\Me\input_file_for_my_program" 2>"C:\Users\Me\my_program_output.log"
But it turns out that the redirect is picked up from the beginning, so I end up with a 0-byte file with the result start
- namely, nothing. Is there a way to make the output redirect somehow tied to the output of my_program?
I've experimented with escaping and neither ^2>
nor 2^>
does it work. Any help would be greatly appreciated!
Try the following:
start "My_Program" "%SystemRoot%\System32\cmd.exe" /c ""C:\Users\Me\my_program.exe" --some --presets --for --my_program.exe --output "C:\Users\Me\output_file_for_my_program" "C:\Users\Me\input_file_for_my_program" 2>"C:\Users\Me\my_program_output.log""
Obviously, without having "My Program" here, I cannot verify this as such. If we assume that the built-in "FIND.EXE" command returns "File not found - filename" on STDERR, the following works for me:
start "My_Program" "%SystemRoot%\System32\cmd.exe" /c "find /v /i "blarg" "c:\not a real file.txt" 2> C:\stderr.txt"
source to share
I used the following command and it worked:
start / affinity 2 / wait cmd.exe / C parameter myprog.exe parameter1 1 ^>. \ a.log 2 →. \ b.log
Link: http://www.pcreview.co.uk/forums/redirect-standard-output-w-start-command-t1467634.html
Abhishek
source to share