Changing Pause Message

ぐ巨炮叔叔 提交于 2021-01-27 04:41:46

问题


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.


回答1:


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



回答2:


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).




回答3:


You may want to try

set /p=your message

Note: you will have to hit the enter key to continue versus any key.




回答4:


Option #1:

@echo off

echo Press any key to continue or Ctrl-C to abort.

pause > nul

Option #2

set /p=Press any key to continue or Ctrl-C to abort.

-->> I prefer the screen output of option #1.




回答5:


This is one practical application:

set /p=Press ENTER key to proceed or Ctrl-C to abort.



来源:https://stackoverflow.com/questions/17559738/changing-pause-message

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