Search code examples
batch-filerake

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

Solution

  • 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.