Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Pause Message

Tags:

batch-file

cmd

Ok, so you know how when you type up pause in CMD, it will say 'Press any key to continue...'. How do I change that to say something like 'Press a key to proceed...'?

Lastly, I was coding a batch file. I want to know what's up if I have something like:

@echo off
cls
pause
pause
pause
pause

It seems to skip round about to pauses When you press a key. I'm curious as to know the rules of which the pauses are skipped. Thanks.

like image 357
user2507295 Avatar asked Jul 09 '13 23:07

user2507295


People also ask

How do I pause CMD output?

Execution of a batch script can also be paused by pressing CTRL-S (or the Pause|Break key) on the keyboard, this also works for pausing a single command such as a long DIR /s listing. Pressing any key will resume the operation.


2 Answers

Nearly the same as Deniz Zoeteman, except this version displays the blinking cursor on the same line as your custom message, as does the normal PAUSE command. The Deniz Zoeteman solution displays the blinking cursor below your message.

<nul set /p "=Press a key to proceed..."
pause >nul
like image 164
dbenham Avatar answered Sep 25 '22 00:09

dbenham


You cannot change the text displayed when a pause command is executed. It's bound to the Windows installation's language pack. The only thing you can do is not letting it say anything by doing pause>nul. Of course, there's different ways to simulate pause; see the example from the other answer, where set /p is used. With pause>nul however, you can do this:

echo Custom pause message

pause>nul

And that should work.

And for pause commands skipping, that's most likely due to the key still being pressed down while the next pause command already executed (small guess though - I don't recall exactly if that's the behaviour of the command).

like image 25
Deniz Zoeteman Avatar answered Sep 26 '22 00:09

Deniz Zoeteman