Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change output of pause command in batch script

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?

like image 573
Hashim Aziz Avatar asked Feb 13 '12 10:02

Hashim Aziz


People also ask

How do I pause command line output?

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.

What is @echo off in batch script?

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.

What is the use of pause in batch file?

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.


1 Answers

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 :)

like image 76
Bali C Avatar answered Sep 19 '22 08:09

Bali C