0

I am trying to username and password protect a certain batch file, and what it needs to do is ask for user input. If that input matches up with whatever is in the .txt file, it will continue executing. For example::

ask username(assign to %usrname%) > ask password(assign to %passwrd%) > check if %usrname% is in usrname.txt > check if %passwrd% is in passwrd.txt > If both check out, goto :next

0

1 Answer 1

2

password and username are case sensitive

@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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.