ask set /p variable on a different line

2019-02-18 18:18发布

问题:

I've seen in batch code that you can ask for user input on a separate line or continue while asking or something. For example it would look something like this;

enter your name
name:_(input would be here)
enter name above

And the code might look like;

echo Enter your name
set /p /(continue) name=name:_
echo enter name above

Or maybe:

echo enter your name
(line 2)
echo enter your name above
set /p /line:2 name=name:_

回答1:

@echo off
setlocal

cls
echo  enter your name
echo name: 
echo enter name above

rem Move cursor to one line below screen size,
rem you must adjust this value to fit your screen.
for /L %%i in (1,1,34) do echo/

rem Move cursor to screen home and hide timeout "Waiting..." message
for /F %%a in ('timeout /T 1 ^> CON') do rem

set /P "name=name: "
echo/
echo/
echo/
echo Name read: "%name%"

Further details at this post