You need two hacks - one to define a carriage return character, and another to echo a line of text without issuing the newline character.
1) Define carriage return.
:: Define CR to contain a carriage return (0x0D)
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
Once defined, the value can only be accessed via delayed expansion - as in !CR!
, not %CR%
.
2) Print text to the screen without issuing a newline
<nul set /p "=Your message here"
This will fail if the string starts with a =
.
Also, leading quotes and/or white space may be stripped, depending on the Windows version
Putting it all together
@echo off
setlocal enableDelayedExpansion
:: Define CR to contain a carriage return (0x0D)
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
<nul set/p"=Part 1 - press a key!CR!"
pause >nul
<nul set/p"=Part 2 - press a key!CR!"
pause >nul
<nul set/p"=Part 3 - Finished !CR!"
Note that I put the !CR!
at the end of each message in preparation for the next. You cannot put the !CR!
at the beginning because leading white space will be stripped.