I\'m writing a Windows batch script. By default, the pause
command will pause the script and display the text "Press any key to continue...".
Starting from Windows 2000 (so, not XP) you can use the choice
command which is far more powerful than either pause
or set /p
.
Besides being able to specify your own prompt text, you can also require the user to type a specific key, and only that key, instead of being limited to, and requiring, [Enter]
to be pressed.
Also, you can prompt the user to press a number of different keys and take action based on which key was pressed.
Type choice /?
for help, or read more about it here: Wikipedia: choice (command)
There is no way to change the text of the pause
command. However you might want to look at the choice
command. You can change the text it prints. The only downside is that you need to provide a list of acceptable characters.
Another dirty solution would be something like this,
SET /P =Press enter to return to the menu . . .
GOTO :menu
The benefit of this is that the cursor stays on the same line as the message, just like with the PAUSE
command.
The downside is that it only listens to the enter key.