0

In Windows 7, I have a batch file that runs an exe in the sub-directory of bat file, it first changes current directory to that folder, then runs the exe. But something goes wrong, I see a console window for a very short time and the program doesn't start. Since the output console is displayed for less than a second, I can't see the error message.

bat file is:

cd /d "%~dp0my_subfolder"
start "" myapplication.exe

How do I redirect the output error message to a text file (the text file will be in the same directory with bat file), so that I can read the error message? What command should I add to the bat file above?

1
  • Not an answer to the question as asked, but as a workaround for the underlying problem you could try adding the pause command after the batch's last command to be able to read the output in the console window before it disappears. Commented Mar 20, 2014 at 13:47

2 Answers 2

1

use:

 start "" myapplication.exe > mytextfile.txt 2>&1

instead you could run batch file from cmd to know what is the error

Sign up to request clarification or add additional context in comments.

3 Comments

Do I need to specify full path of text file?
It's optional. If you donot specify the path, file would be created at "%~dp0my_subfolder".
I tried, but it doesn't write anything to the file.
1

Try this, to see the error message:

cd /d "%~dp0my_subfolder"
start "" /b myapplication.exe
pause

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.