How to skip pause in batch file

Batch File

Batch File Problem Overview


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.

Batch File Solutions


Solution 1 - Batch File

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.

Solution 2 - Batch File

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStanView Question on Stackoverflow
Solution 1 - Batch FilePatrick CuffView Answer on Stackoverflow
Solution 2 - Batch FileStefan EgliView Answer on Stackoverflow