Batch file Programming Help required -
i writing batch file program gets username , password user , checks them comparing them 2 files, username.dat , password.dat.
the username stored in %username% , password in %password%. i'd know is, how check these variables against files username.dat , password.dat?
i've tried using this:
echo %username% >u.dat echo %password% >p.dat comp u.dat username.dat but value check? mean in c or c++ can check return value, comp?
storing username , password in files seems bad idea me. assuming going way...
there no need echo variables temporary files prior doing comparison. there multiple ways comparison more directly. here 1 method. i'm using delayed expansion supports special characters & | etc in password (or username).
setlocal enabledelayedexpansion set userpassok=1 findstr /x /c:"!username!" username.dat || set "userpassok=" findstr /x /c:"!password!" password.dat || set "userpassok=" if defined userpassok (echo username , password passed) else echo invalid username/password
Comments
Post a Comment