My batch informs the user when the value entered is wrong and offers two options: retype the value or exit the program.
@echo off
cls
setlocal enabledelayedexpansion
set /p _Value=Enter the value:
for /f skip^=4 %%e in ('echo;prompt $E^|cmd')do set "_$E=%%e"
if "!_Value!" gtr "10" (
echo %_$E%[31mInvalid value! Do you want to re-enter the value? (y=yes/n=exit) %_$E%[0m
IF /i "!r!"=="y" goto RELOADSAMESCREEN
goto :eof
)
The only way I managed to make the message disappear when the retype option is chosen, was to reload the same screen because when the screen is reloaded, the CLS command clears the screen with the message and then loads the screen again, so the message disappears from the screen and the user can re-enter the value without the error message.
How can I clear the message sent by the echo command without having to reload the same screen?