我使用了“批处理文件,要求输入用户名/密码+注册”(主题已经在stackoverflow中)...这里是我的问题:有没有办法可以将锁定添加到批处理文件或5次错误尝试后执行关机命令? (底部超时为24小时) 示例情况: 用户名:bobTESTattempt1 密码:1234 [输入] 密码错误4次尝试!
(使用接下来的3次尝试)
用户名:bobTestattempt5 密码123342 [输入] 密码错误0尝试剩余! [输入]
账号被锁定 TIMEOUT 86400
答案 0 :(得分:0)
你去吧
@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