批量检查输入文本文件?

时间:2013-12-19 02:23:59

标签: batch-file cmd dos

我正在尝试用户名和密码保护某个批处理文件,它需要做的是询问用户输入。如果该输入与.txt文件中的任何内容匹配,它将继续执行。例如::

询问用户名(分配给%usrname%)>问密码(分配给%passwrd%)>检查%usrname%是否在usrname.txt>中检查%passwrd%是否在passwrd.txt中>如果两个都退房,请转到:下一个

1 个答案:

答案 0 :(得分:2)

密码和用户名区分大小写

@echo off
set "fail="
set "username="
set "password="
set /p "username=Enter your scurvy username, Arrr : "
set /p "password=What be your Pirate Password? : "
findstr /b /e /l /c:"%username%" <"usrname.txt" >nul || set fail=1
findstr /b /e /l /c:"%password%" <"passwrd.txt" >nul || set fail=1
if defined fail (
   echo Begone you lily livered land-lubber!
   pause>nul
   goto :EOF
)
REM rest of code here