I am trying this as user input:
Code: Select all
@echo off
for /f %%i in ('sc ^>nul') do echo %%i
pause
It has an advantage that it can handle Ctrl+C, Ctrl+Z, and some other "special" chars. It also does not echo the CRLF.
Sample Output (Pressing Ctrl+C):
Code: Select all
♥Press any key to continue . . .
Now, I will try to NOT print the char and store it instead to a variable. I tried this,
Code: Select all
@echo off
for /f %%i in ('sc ^>nul') do set "key=%%i" >nul
But when I press something (again, Ctrl+C), it still displays the char pressed!
Output:
Code: Select all
♥
EDIT:
It also does not store the char to the "key" variable.
Is there a way to not display the key pressed? Thanks everyone!!!
Meerkat