Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Press ANY Key?

30 views
Skip to first unread message

pro...@berkeley.edu

unread,
May 14, 2017, 1:11:10 PM5/14/17
to
==========begin "c:\Cmd\demo\PressAnyKey.cmd" ==========
01. @echo off
02. echo/PAUSE Suspends processing of a batch program and displays the message
03. echo/ Press any key to continue . . .
04. echo/
05. echo/To skip to the NEXT iteration, press ANY key???
06. echo/
07. echo/Yeah, any key EXCEPT an ARROW key or DELETE key
08. echo/or HOME key or END key or INS key or Fn key ...
09. echo/in which case you will advance TWO.
10. echo/
11. echo/
12. for /l %%i in (1,1,99) do (
13. echo/ This is iteration #%%i
14. pause
15. )
==========end "c:\Cmd\demo\PressAnyKey.cmd" ==========

It's a minor annoyance that PAUSE behaves in this way, skipping once,
skipping twice, or not at all for some keys (CAPS LOCK, NUM LOCK, etc.).
Is there any way of getting PAUSE to behave more uniformly?

--
Phil Robyn


Mike Sanders

unread,
May 15, 2017, 7:55:26 AM5/15/17
to
pro...@berkeley.edu wrote:

> Is there any way of getting PAUSE to behave more uniformly?

Hi Phil, just a shot in the dark (still
learning cmd language on this end...) try:

pause > nul | set/p =any key to iterate...

An aside because I'm not sure it matters,
but I used the fragment above as more fully
shown next, to determine weather or not the
batch file was launched via a double-click
or from within an existing instance of %comspec%:

:: if script pauses here, it was launched from explorer
if %0=="%~0" pause > nul | set/p =any key to exit...

--
later on,
Mike

https://busybox.hypermart.net
0 new messages