Changing the PAUSE prompt

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Changing the PAUSE prompt

#1 Post by alleypuppy » 01 Jan 2012 17:52

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

Code: Select all

ECHO [message]
PAUSE > NUL
trick, but the blank line under the message annoys me. Is there any way to get rid of this blank new line?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Changing the PAUSE prompt

#2 Post by aGerman » 01 Jan 2012 18:47

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

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Changing the PAUSE prompt

#3 Post by alleypuppy » 01 Jan 2012 21:26

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?

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Changing the PAUSE prompt

#4 Post by Aacini » 03 Jan 2012 20:38

Just change your ECHO by SET /P =[message]< NUL

Code: Select all

SET /P =[message]< NUL
PAUSE > NUL

The < redirector indicate the command to take its input from the file instead the keyboard. NUL is the standard "empty" DOS file.

©opy[it]®ight
Posts: 60
Joined: 17 Mar 2012 09:59

Re: Changing the PAUSE prompt

#5 Post by ©opy[it]®ight » 17 Mar 2012 10:03

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-files

PAUSE>NUL|SET /P =[optional] did the trick for me.

Thank you aGerman, and thank you dostips.com!

Best regards,
©opy[it]®ight

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Changing the PAUSE prompt

#6 Post by dbenham » 17 Mar 2012 11:22

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.

Code: Select all

pause>nul|set/p=[message]&echo(

This seems a good candidate for a macro :!: :D

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

Post Reply