Page 1 of 1
Changing the PAUSE prompt
Posted: 01 Jan 2012 17:52
by alleypuppy
Hello,
This is sort of a dumb question, but is it possible to modify the PAUSE prompt witout creating a new line under the new prompt? I am aware of the
trick, but the blank line under the message annoys me. Is there any way to get rid of this blank new line?
Re: Changing the PAUSE prompt
Posted: 01 Jan 2012 18:47
by aGerman
It's possible even if it looks a bit odd
Code: Select all
pause>nul|set /p "=[message]"<nul&echo(
The "echo(" let the cursor jump to the next line after you hit a key.
Regards
aGerman
Re: Changing the PAUSE prompt
Posted: 01 Jan 2012 21:26
by alleypuppy
aGerman wrote:It's possible even if it looks a bit odd
Code: Select all
pause>nul|set /p "=[message]"<nul&echo(
The "echo(" let the cursor jump to the next line after you hit a key.
Regards
aGerman
Works perfectly! Thanks! I figured I needed to include SET /P in there somewhere, but I wasn't sure how. I just have one question: what does the < character do? I know > and >> are used for redirection. Is < used for feedback or something?
Re: Changing the PAUSE prompt
Posted: 03 Jan 2012 20:38
by Aacini
Just change your ECHO by SET /P =[message]< NUL
The < redirector indicate the command to take its input from the file instead the keyboard. NUL is the standard "empty" DOS file.
Re: Changing the PAUSE prompt
Posted: 17 Mar 2012 10:03
by ©opy[it]®ight
I'm so glad i found this forum/topic!
Even though i'm not looking for a solution on how to change the PAUSE prompt, i've been looking for a decent pause replacement for ages.
This to work around the problem where a second pause irritation would be skipped if any of the function- or arrow-keys were pressed:
http://stackoverflow.com/questions/6958272/arrow-keys-trigger-pause-twice-in-windows-batch-filesPAUSE>NUL|SET /P =[optional] did the trick for me.
Thank you
aGerman, and thank you
dostips.com!
Best regards,
©opy[it]®ight
Re: Changing the PAUSE prompt
Posted: 17 Mar 2012 11:22
by dbenham
That is an interesting simplification - the <nul is not required. Also the quotes are not needed unless the message contains special characters. But the &echo( should be preserved so that the cursor moves to the next line properly.
This seems a good candidate for a macro
Code: Select all
@echo off
:: Define a PAUSE macro that properly handles arrow and function key presses
:: and also allows a custom pause message
set pause=for %%n in (1 2) do if %%n==2 (for /f "eol= tokens=*" %%a in ("!args!") do (endlocal^&pause^>nul^|set/p=%%a^&echo()) else setlocal enableDelayedExpansion^&set args=
:: Demonstrate usage of the PAUSE macro
echo Part 1
%pause% Press any key to continue . . .
echo Part 2
%pause% Custom pause message . . .
echo Part 3
Dave Benham