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...".
How do I modify this text to display my own text to the user?
Execution of a batch script can also be paused by pressing CTRL-S (or the Pause|Break key) on the keyboard, this also works for pausing a single command such as a long DIR /s listing. Pressing any key will resume the operation. Pause is often used at the end of a script to give the user time to read some output text.
batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.
You can insert the pause command before a section of the batch file that you might not want to process. When pause suspends processing of the batch program, you can press CTRL+C and then press Y to stop the batch program.
You could hide the text from the pause
command by using this:
pause >nul
Then you could echo your own message to tell the user it has paused:
echo The batch file has paused
So the full script might look like this:
@echo off echo Hello World! echo The batch file has paused pause >nul
Hope this helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With