Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect output from exe after it has terminated?

I'm trying to save the output of an exe file executed within a batch file to a text file. I've tried the the following methods but they don't work

This doesn't work since I'm back at the command prompt while the application runs and the text file created is blank.

C:\>myexec.exe > mytext.txt

C:\>_

C:\>Status: Passed

These also doesn't work. I get an empty text file and no output.

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

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

This gives me an output at least:

C:\>start /wait myexec.exe
Status Passed
like image 952
user772112 Avatar asked Oct 24 '25 02:10

user772112


2 Answers

Use /B operator.

This will cause the output to be redirected

start /B /wait myexec.exe > mytext.txt

like image 185
Siddharth Avatar answered Oct 27 '25 01:10

Siddharth


I had the same issue and solved it like this:

bat file content

START /wait cmd /c "F:\MyInstaller\installer.exe > log.txt"

echo This will get logged after the previous is completed > log1.txt

like image 41
Siddharth Sinha Avatar answered Oct 27 '25 01:10

Siddharth Sinha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!