[2/2] cmd: Make PAUSE accept any keypress instead of a full input line (resend)

Frédéric Delanoy frederic.delanoy at gmail.com
Fri Oct 7 02:07:37 CDT 2011

All Windows versions wait for a single keypress.
Wine was waiting for a full EOL-terminated line to be entered.
 programs/cmd/builtins.c |   21 +++++++++++++++------
 programs/cmd/cmd.rc     |   11 ++++++-----
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 6b4d0ab..1db9b3c 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1685,16 +1685,25 @@ void WCMD_move (void) {
  * WCMD_pause
- * Wait for keyboard input.
+ * Suspend execution of a batch script until a key is typed
-void WCMD_pause (void) {
+void WCMD_pause (void)
+  DWORD oldmode;
+  BOOL have_console;
   DWORD count;
-  WCHAR string[32];
+  WCHAR key;
+  have_console = GetConsoleMode(hIn, &oldmode);
+  if (have_console)
+      SetConsoleMode(hIn, 0);
-  WCMD_output (anykey);
-  WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string)/sizeof(WCHAR), &count);
+  WCMD_output(anykey);
+  WCMD_ReadFile(hIn, &key, 1, &count);
+  if (have_console)
+    SetConsoleMode(hIn, oldmode);
diff --git a/programs/cmd/cmd.rc b/programs/cmd/cmd.rc
index 0786680..c11f9ad 100644
--- a/programs/cmd/cmd.rc
+++ b/programs/cmd/cmd.rc
@@ -122,10 +122,10 @@ variable, for example:\n\
 		PATH %PATH%;c:\\temp\n"
-"PAUSE displays a message on the screen 'Press Return key to continue'\n\
-and waits for the user to press the Return key. It is mainly useful in\n\
-batch files to allow the user to read the output of a previous command\n\
-before it scrolls off the screen.\n"
+"PAUSE displays a message on the screen asking the user to press a key.\n\
+It is mainly useful in batch files to allow the user to read the output\n\
+of a previous command before it scrolls off the screen.\n"
 "PROMPT sets the command-line prompt.\n\
@@ -271,6 +271,7 @@ MD (MKDIR)\tCreate a subdirectory\n\
 MORE\t\tDisplay output in pages\n\
 MOVE\t\tMove a file, set of files or directory tree\n\
 PATH\t\tSet or show the search path\n\
+PAUSE\t\tSuspend execution of a batch file\n\
 POPD\t\tRestore the directory to the last one saved with PUSHD\n\
 PROMPT\t\tChange the command prompt\n\
 PUSHD\t\tChange to a new directory, saving the current one\n\
@@ -317,7 +318,7 @@ Enter HELP <command> for further information on any of the above commands.\n"
   WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
   WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
   WCMD_NOPATH, "PATH not found\n"
-  WCMD_ANYKEY,"Press Return key to continue: "
+  WCMD_ANYKEY,"Press any key to continue... "
   WCMD_CONSTITLE,"Wine Command Prompt"
   WCMD_VERSION,"CMD Version %s\n"

More information about the wine-patches mailing list