Change output of pause command in batch script

后端 未结 9 470
孤独总比滥情好
孤独总比滥情好 2020-12-24 11:14

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

相关标签:
9条回答
  • 2020-12-24 12:08

    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)

    0 讨论(0)
  • 2020-12-24 12:12

    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.

    0 讨论(0)
  • 2020-12-24 12:12

    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.

    0 讨论(0)
提交回复
热议问题