Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do "press enter to exit" in batch

I am using rake to build my project and I have a build.bat file similar to this:

@echo off cls rake 

When I double click on build.bat the dos window pops up and shows all the progress but closes itself when the task is finished. Is there way to do a Console.ReadLine so that user can get a chance to see the log?

Thanks.

Updated:

I've tried below but didn't work. not sure why.

@echo off cls rake pause 
like image 254
Jeff Avatar asked Sep 22 '09 07:09

Jeff


People also ask

How do I exit batch mode?

Using EXIT /B will stop execution of a batch file or subroutine and return control to the command processor or to the calling batch file or code immediately. EXIT /B is available in Windows 2000 and later versions' CMD.

How do I press a keyboard key in a batch file?

The example below will open a browser window and press the Tab key to move on the input field. The code for our example will look like the below. In the above example, through the line SET SendKeys=CScript //nologo //E:JScript "%~F0" , we send keys to the keyboard buffer by using %SendKeys% .

How set enter in batch file?

bat "progfortr" "{ENTER}" call sendkeys. bat progfortr.exe "{ENTER}" call sendkeys.

How do I create a line break in batch file?

To create a blank line in a batch file, add an open bracket or period immediately after the echo command with no space, as shown below. Adding @echo off at the beginning of the batch file turns off the echo and does not show each of the commands. @echo off echo There will be a blank line below.


2 Answers

Default interpreters from Microsoft are done in a way, that causes them exit when they reach EOF. If rake is another batch file, command interpreter switches to it and exits when rake interpretation is finished. To prevent this write:

@echo off cls call rake pause 

IMHO, call operator will lauch another instance of intepretator thereby preventing the current one interpreter from switching to another input file.

like image 94
Basilevs Avatar answered Sep 28 '22 04:09

Basilevs


pause 

will display:

Press any key to continue . . .

like image 35
Steven Robbins Avatar answered Sep 28 '22 05:09

Steven Robbins