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


See More: Batch file login not working

Report •


#1
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