The following programm ignores the first input, will ask again and only then accept the input.
@echo off
SETLOCAL
IF EXIST C:\Windows\notepad.exe (
:confirm
SET /P confirm="overwrite? yn "
echo entered: %confirm%
IF /I "%confirm%"=="y" GOTO overwrite
IF /I "%confirm%"=="n" GOTO no
GOTO confirm
:no
echo You selected no.
exit 1
:overwrite
echo You selected yes.
)
Entering y<ENTER>
, y<ENTERY>
will result in the output:
overwrite? yn y
entered:
overwrite? yn y
entered: y
You selected yes.
Entering y<ENTER>
, n<ENTER>
will result in the output:
overwrite? yn y
entered:
overwrite? yn n
entered: n
You selected no.
I start the programm with cmd /k input-test.cmd
.
Removing the IF EXIST
will remove that bug.