Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Logging in failing (batch)  (Read 2945 times)

0 Members and 1 Guest are viewing this topic.

Helpmeh

    Topic Starter


    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Logging in failing (batch)
« on: April 19, 2009, 09:17:47 AM »
I am trying to make get a user to log in, to use the batch script, but the login is failing in the second FOR loop...

Here is my code. List.txt is a file with about 30 lines, each different. The first word is a possible username, the second a possible password. No usernames are the same.

Code: [Select]
@echo off
setlocal enabledelayedexpansion
set fname=list.txt
:looplog
set num1=0
set num2=0
echo Enter your username.
set /p usr=Username^:
Echo Enter your password.
set /p pass=Password^:
pause
for /f "delims=" %%z in ('type %fname%') do (
set /a num1+=1
)
echo Lines^: %num1%
pause
for /f "tokens=1-2 delims= " %%a in ('type %fname%') do (
if "%%a"=="%usr" if "%%b"=="%pass%" goto cont
set /a num2+=1
if %num2%==%num1% cls & echo Username and/or password don't match. & goto looplog
)
:cont
echo HI!
pause

For some reason, the second FOR loop is not LOOPING...so it just keeps on going as if it didn't exist...
« Last Edit: April 19, 2009, 11:21:18 AM by Helpmeh »
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Logging in failing (batch)
« Reply #1 on: April 19, 2009, 07:43:35 PM »


if "%%a"=="%usr" if "%%b"=="%pass%" goto cont

Helpmeh

    Topic Starter


    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: Logging in failing (batch)
« Reply #2 on: April 22, 2009, 04:06:21 PM »

if "%%a"=="%usr" if "%%b"=="%pass%" goto cont
I did not see that...
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.