How do I create pasword protection in batch file but that now one can see password on screen? Thank you for any answer.
with choice, password in this example = testing @echo off&setlocal enabledelayedexpansion set loop=0 set lenght=7 echo Password: :loop set/a loop+=1 choice /c ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 >nul ::echo %errorlevel% set "char!loop!=!errorlevel!" if '!loop!'=='%lenght%' goto :check goto :loop :check set password= for /l %%a in (1,1,7) do ( set "password=!password!!char%%a!" ) if "20519209147"=="!password!" ( echo correct ) else ( echo incorrect ) pause>nul
You can try by this method : @echo off Title Mask an input text in a bat file :Main cls SetLocal Call :TypePassword "Type your password" password1 Call :TypePassword "Retype your password" password2 cls If [%password1%] EQU [%password2%] ( color 0A echo The password read is: "%password2%" Timeout /T 5 /NoBreak>nul ) Else ( Color 0C echo The Password is wrong ! echo Try again ! Timeout /T 2 /NoBreak>nul Goto Main ) Exit ::---------------------------------- :TypePassword <Message> <Password> set /P "=_" < NUL > "%~1" Findstr /A:1E /V "^$" "%~1" NUL>CON Del "%~1" set /P "%~2=" Exit /B ::----------------------------------
Thank You Very Much!!! :)