如何批量“按进退出”

我使用 rake 来构建我的项目,我有一个 build.bat 文件,类似于下面这样:

@echo off
cls
rake

当我双击 build.bat 时,dos 窗口会弹出并显示所有的进度,但是当任务完成时会自动关闭。有没有办法做一个控制台。ReadLine,以便用户可以有机会看到日志?

谢谢。

更新:

我试过下面的方法,但是没有用。不知道为什么。

@echo off
cls
rake
pause
260387 次浏览

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
pause

will display:

Press any key to continue . . .

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.

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

Use this snippet:

@echo off
echo something
echo.
echo press enter to exit
pause >nul
exit
@echo off
echo something
echo Press enter to exit
set /p input=
@echo off
echo Press any key to exit . . .
pause>nul