Solved How to create pasword in batch file but that it is invisible

April 26, 2020 at 05:09:48
Specs: Windows 10
How do I create pasword protection in batch file but that now one can see password on screen? Thank you for any answer.

See More: How to create pasword in batch file but that it is invisible

Reply ↓  Report •

#1
April 26, 2020 at 07:39:05
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

specs: https://www.userbenchmark.com/UserR...


Reply ↓  Report •

#2
April 26, 2020 at 09:32:55
✔ Best Answer
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
::----------------------------------


Reply ↓  Report •

#3
April 27, 2020 at 09:05:39
Thank You Very Much!!! :)

Reply ↓  Report •
Related Solutions


Ask Question