0

I am using this simple menu in cmd where I padded my ECHOs with TAB key:

:MENU

ECHO    select this by pressing 0
ECHO(
ECHO    select this by pressing 1
ECHO(
SET /P ANSWER="press something:"

is there a way how to padd the output of SET /P ANSWER= ??

I tried with TAB it and/or SPACE it, but non works. it looks like this:

     select this by pressing 0

     select this by pressing 1

press something:_

and I want it to look like this:

     select this by pressing 0

     select this by pressing 1

     press something:_
1

You can use some control character e.g. backspace (U+0008) as in the following code snippet; a hint: single key-presses can be captured from the keyboard using choice command (see the script)

@ECHO OFF
SETLOCAL EnableExtensions

     rem get backspace character to BS variable
for /F %%a in ('echo prompt $H ^| cmd') do set BS=%%a

:MENU
ECHO(
ECHO    select this by pressing 0
ECHO(
ECHO    select that by pressing 1
ECHO(
     rem       ↓ this character is deleted in output by backspace
SET /P "ANSWER=X%BS%   press something: "
ECHO(
echo    "%ANSWER%" entered; another approach using CHOICE command:
ECHO(
CHOICE /C 01 /N /M "X%BS%   Select [0] this or [1] that: "

Output:

==> D:\bat\SU\1324661.bat

   select this by pressing 0

   select that by pressing 1

   press something: s

   "s" entered; another approach using CHOICE command:

   Select [0] this or [1] that: 1

==>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.