[batch-file] 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

This question is related to batch-file rake

The answer is


My guess is that rake is a batch program. When you invoke it without call, then control doesn't return to your build.bat. Try:

@echo off
cls
CALL rake
pause

@echo off
echo somethink
echo Press enter to exit
set /p input=

pause

will display:

Press any key to continue . . .


Use this snippet:

@echo off
echo something
echo.
echo press enter to exit
pause >nul
exit

Oops... Misunderstood the question...

Pause is the way to go

Old answer:

you can pipe commands into your patch file...

try

build.bat < responsefile.txt

@echo off
echo Press any key to exit . . .
pause>nul