Reputation: 41
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
Upvotes: 4
Views: 27590
Reputation: 370
The &
redirection operator duplicates output or input from one specified handle to another specified handle. For example, to send dir
output to File.txt
and send the error output to File.txt
, type:
dir>c:\file.txt 2>&1
Upvotes: 0
Reputation: 51
Use /B operator.
This will cause the output to be redirected
start /B /wait myexec.exe > mytext.txt
Upvotes: 5
Reputation: 41
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
Upvotes: 2
Reputation: 635
Try Application.exe >& file.txt
. This will output both, standard output and error stream, to your file.
Upvotes: -2