Question

I am making a batch file (login.cmd) that calls login variables from a signup file (signup.cmd); but I don't know exactly how to do it.

signup.cmd

::Copyright 2014 Krii.
@echo off
color f0
title Sign Up
echo Welcome,
set /p usern=Choose Username: 
set /p passwd=Choose Password: 
set /p bd=BD mm/dd/yyyy: 
set /p email=Email: 
echo USER >> docs/users.txt
echo ==== >> docs/users.txt
echo Username=%usern% >> docs/users.txt
echo Password=%passwd% >> docs/users.txt
echo BD=%bd% >> docs/users.txt
echo Email=%email% >> docs/users.txt
cls
echo Thank You.
echo.
echo Press any key to Login. . .
pause >nul
start login.bat
exit

login.cmd

::Copyright 2014 Krii.
@echo off
color f0
title Login
echo Please login to continue.
set /p usern=Username:
set /p passwd=Password:

=> => =>

if %usern%==%usern% in signup.cmd && %passwd%==%passwd% in signup.cmd goto authGood
goto authBad

=> => =>

There is an error in line 7 and 8 in login.cmd. I can't figure out what to do.

Please Help
Thanks.

Was it helpful?

Solution

in is not a command, but part of the syntax of the forcommand.

IF has no in

you can simply import the variables from your file:

cd docs
for /f "delims=" %%i in (users.txt) do set %%i

then get the new variables:

set /p usern=Username:
set /p passwd=Password:

and compare the old variables to the new variables:

if %usern%==%Username% if %paswd%==%Password% goto authGood
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top