Question

I have used the script from "batch file which asks for username/password + registration" (topic already in stackoverflow)... here's my question: Is there any way that i could add a lockout to a batch-file or execute a shutdown command after 5 incorrect attempts? (the timeout at the bottom is for 24 hours) Example Situation: Username: bobTESTattempt1 Password: 1234 [enter] Password is incorrect 4 attempts remaining!

(the next 3 attempts are used)

Username: bobTestattempt5 Password 123342 [enter] Password is incorrect 0 attempts remaining! [enter]

ACCOUNT LOCKED OUT TIMEOUT 86400

Was it helpful?

Solution

Here you go

@echo off
set counter=5
:CREDS
cls
if %counter% equ 0 goto :LOCKOUT
if %counter% lss 5 echo Password incorrect, %counter% attempts left
set /p un=Enter your username:
set /p pw=Enter your password:
if %un%==correctusername (
if %pw%==correctpassword goto :ALLOK
)
goto :WRONG

:WRONG
set /a counter-=1
goto :CREDS

:ALLOK
echo Creds ok, do whatever
pause >nul
exit >nul

:LOCKOUT
echo ACCOUNT LOCKED OUT TIMEOUT 86400
timeout /t 86400
goto :CREDS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top