Solved Batch file login not working

January 17, 2015 at 06:25:13
Specs: Windows 8
im trying to make a login, but for some reason it always goes to wng. (wrong) here is the code

set /a trs=3
if exist %cd%\files\User1\password1.123 goto log
goto reg
Title Register
set /p pass=Enter Password:
echo %pass% >> %cd%\files\User1\password1.123
echo Registered
goto log
Title Login
echo Tries left: %trs%
echo Enter Password:
set /p pass=
if %pass%==%~dp0\files\User1\password1.123 goto desktopuser1
if %trs%==1 exit
set /a trs=%trs%-1
echo Username or Password is incorrect.
echo Press enter to continue.
pause >nul
goto log

See More: Batch file login not working

Report •

January 17, 2015 at 09:10:10
✔ Best Answer
if %pass%==%~dp0\files\User1\password1.123 goto desktopuser1
You are comparing the password string with the path where it is stored, that's why the script always reports an error message. You have to code instead

set /P pwstring=< %~dp0\files\User1\password1.123 goto desktopuser1
if %pass%==%pwstring% goto desktopuser1

and when you store your password code

(echo %pass%) >> %cd%\files\User1\password1.123

otherwise a blank is added at its end or if numeric the wrong redirector is invoked.

Report •
Related Solutions

Ask Question