How to skip pause in batch file

拟墨画扇 提交于 2019-12-17 16:25:19

问题


In windows batch file, if myScript.bat runs otherScript.bat, and in otherScript.bat, there's a pause in first line. How can I send a keystroke to skip that pause in myScript.bat? So my script won't need to take any extract keystroke and won't be blocked by the pause. Thanks.


回答1:


One way would be to use the echo command to do the keystroke for you.

For example:

myScript.bat

@echo OFF

@echo Calling otherScript.bat...
@echo | call otherScript.bat
@echo Done.

otherScript.bat

pause
@echo Hello World

Stefan's solution is more flexible and allows you to control when to pause or not, but this solution will work if you're not able to revise otherScript.bat for some reason.




回答2:


You could modify otherScript.bat so that it accepts an optional parameter, telling it to skip the pause command like this:

if "%1"=="nopause" goto start
pause
:start


来源:https://stackoverflow.com/questions/3583565/how-to-skip-pause-in-batch-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!