Você pode usar algum caractere de controle, por exemplo backspace ( U+0008
) como no trecho de código a seguir; uma dica: as teclas únicas podem ser capturadas do teclado usando choice
command (consulte o 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: "
Saída :
==> D:\bat\SU24661.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
==>