11 Vote

Batch-Script: CMD Window should remain open after Program Run

Question by CSchaf | 2014-09-04 at 12:37

I have written a small batch script that is calling and executing a program. This application is writing some information into the console (I mean the black CMD or command line interpreter window that is opened when clicking on a BAT-file).

My problem is that Windows automatically closes the window, so that I can not see the output of my program. I have already tried to take a screenshot exactly at the moment the window shortly pops up, but this is not a good solution.

Is there any possibility to keep the command prompt window open and not to close it automatically?

ReplyPositiveNegativeDateVotes
3Best Answer3 Votes

You can just use the command "pause".

For example in the following way:

@echo off
prog.exe
pause

This batch script executes the program "prog.exe" and as soon as the script comes across the line "pause", it stops. Then, the message "Please press any key..." is displayed and only after pressing a key, the script will be resumed and with this the window is closed.

Using this command, you should be able to read the output of the program without any problems.
2014-09-04 at 14:54

ReplyPositive Negative
00 Votes

You could also do that as an example:

@echo off
@echo Hello
timeout 7

timeout will then stop the script for the specified time.
2022-10-30 at 20:49

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.