callus
callus

Reputation: 3

How to display text next "set /p"

Not beneath, but next to "set /p".

My code is

set /p "input=Input: " && echo Test

What I want the output to be is

Input: [input text here] Test

How do I do this?

Upvotes: 0

Views: 200

Answers (1)

Aacini
Aacini

Reputation: 67256

This works in all Windows versions excepting Windows 10:

@echo off
setlocal EnableDelayedExpansion

rem Get BS, CR and TAB characters
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
set "TAB="
for /F "skip=4 delims=pR tokens=2" %%a in ('reg query hkcu\environment /v temp' ) do set "TAB=%%a"
for /F "tokens=2 delims=0" %%a in ('shutdown /? ^| findstr /BC:E') do if not defined TAB set "TAB=%%a"

set /p "input=Input: "
echo !TAB!!BS!!BS!!CR!Input: !input! Test

In order for Windows 10 to work you need to enable Legacy console mode.

Further details at Move cursor to any position using just ECHO command

Upvotes: 1

Related Questions