简体   繁体   English

有什么方法可以重定向Windows命令行中以“开始”运行的命令的stderr输出?

[英]Is there any way to redirect stderr output from a command run with “start” in the Windows command line?

I have a program that I want to automate runs for, since it takes awhile to complete. 我有一个要自动运行的程序,因为它需要一段时间才能完成。 For some reason it outputs everything to stderr instead of stdout, and I'd like to check on its progress, so I find myself needing to redirect stderr output within a start command. 由于某种原因,它会将所有内容输出到stderr而不是stdout,并且我想检查其进度,因此我发现自己需要在启动命令中重定向stderr输出。

I 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 being picked up by start, so that I get a 0-byte file with the result of "start" - namely, nothing. 但是事实证明重定向是由start进行的,因此我得到一个0字节的文件,其结果为“ start”-即什么也没有。 Is there any way to make the output redirection attach in some way to the output of my_program? 有什么办法可以使输出重定向以某种方式附加到my_program的输出上?

I've experimented with escaping, and neither "^2>" nor "2^>" seem to work. 我已经尝试过转义,“ ^ 2>”和“ 2 ^>”似乎都没有用。

如果“面向变通办法的编程”是可以接受的(可能是,您正在对Windows Batch进行编程),则可以将有问题的代码行放在另一个.BAT文件中,而无需任何“启动”,然后“启动”该另一个BAT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM