简体   繁体   English

如何将输出从可执行文件重定向到批处理文件的调用方?

[英]How to redirect output from an executable to a batch file's caller?

In a batch file, how can I start an executable and redirect the output, as if the caller of the batch file started the executable itself? 在批处理文件中,如何启动可执行文件并重定向输出,就像批处理文件的调用者启动了可执行文件本身一样?

process.exe > batch.bat > commandline.exe
---------------------------------< Output

You might want to read up on input/output streams and how to redirect them. 您可能想要阅读输入/输出流以及如何重定向它们。 An excellent article about that: http://www.robvanderwoude.com/battech_redirection.php 一篇很棒的文章: http : //www.robvanderwoude.com/battech_redirection.php

In your case, @ECHO OFF at the start of your batch file will probably do the trick. 就您而言,批处理文件开头的@ECHO OFF可能会解决问题。 If you include that, only explicit outputs (such as those from commandline.exe in your example) will "bubble up" and reach the caller. 如果包括这些内容,则仅显式输出(例如您示例中的commandline.exe输出)将“冒泡”并到达调用者。

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

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