本文介绍了怎么做“按Enter键退出"分批的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用rake来构建我的项目,并且我有一个类似于以下内容的build.bat文件:

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

@echo off
cls
rake

当我双击build.bat时,dos窗口会弹出并显示所有进度,但在任务完成时会自行关闭.有没有办法做Console.ReadLine,以便用户有机会查看日志?

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?

谢谢.

已更新:

我在下面尝试过,但是没有用.不知道为什么.

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

@echo off
cls
rake
pause

推荐答案

Microsoft的默认解释器以某种方式完成,导致它们到达EOF时退出.如果rake是另一个批处理文件,则命令解释器将切换到该文件,并在rake解释完成后退出.为了防止这种写法:

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.

这篇关于怎么做“按Enter键退出"分批的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 05:38