0

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.

Krii
  • 907
  • 9
  • 23
  • @aphoria " 'in' is not recognized as an internal or external command, operable program or batch file". But it is a command. – Krii May 07 '14 at 15:31
  • Take a look at [this](http://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file/20343074#20343074) if you want to mask the password input. – unclemeat May 07 '14 at 23:11

1 Answers1

2

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
Krii
  • 907
  • 9
  • 23
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • Doesn't work. Says "------- 'DOCS/USERS.TXT' is not defined." – Krii May 08 '14 at 19:15
  • do you have a space in `"delims= "`? If yes, remove it. – Stephan May 08 '14 at 19:36
  • ah - no. I think, you have `"delims=="` – Stephan May 08 '14 at 19:39
  • @Krii: nice edit. The `find "="` was there to process not all lines. (you had some lines in your example that will lead to errors or may unintended delete variables). The `"` were there to prevent syntax errors, if a variable is emty. – Stephan May 09 '14 at 15:27