如何在 exe 终止后重定向输出?

use*_*112 4 redirect command-line dos batch-file

我正在尝试将批处理文件中执行的 exe 文件的输出保存到文本文件中。我尝试过以下方法但不起作用

这不起作用,因为当应用程序运行时我回到命令提示符并且创建的文本文件是空白的。

C:\>myexec.exe > mytext.txt

C:\>_

C:\>Status: Passed

这些也行不通。我得到一个空文本文件并且没有输出。

C:\>start /wait myexec.exe > mytext.txt

C:\>call start /wait myexec.exe > mytext.txt

这至少给了我一个输出:

C:\>start /wait myexec.exe
Status Passed
Run Code Online (Sandbox Code Playgroud)

小智 5

使用 /B 运算符。

这将导致输出被重定向

启动 /B /wait myexec.exe > mytext.txt