Batch GOTO Function?

Microsoft Windows 7 home premium upgrade...
June 21, 2010 at 21:01:59
Specs: Windows 7
I'm having some problem with this. IT can't go thou :PASSCHKX

@echo off
echo Please put the username and password below
set /P USERCHK="USERNAME:"
set /P PWDXCHK="PASSWORD:"
cls
echo Logging in..
if %USERCHK%==myuser SET UC=1
if %PWDXCHK%==mypass SET PC=1
if %USERCHK%==admin SET UCX=2
if %PWDXCHK%==password SET PCX=2

wait 3
IF %UC%==%PC% SET LC=1
IF %UCX%==%PCX% SET LC=2
IF %LC%==1 (GOTO PASSCHK)
ELSE (%LC%==0 GOTO BADLOGIN)
IF %LC%==2 (GOTO PASSCHKX)
ELSE (%LC%==0 GOTO BADLOGIN)

:BADLOGIN
echo Wrong Username or Password.

:PASSCHK
echo LC1 zone
GOTO END


thx in advance :D
:PASSCHKX
echo LC2 zone
GOTO END

:END
pause


See More: Batch GOTO Function?

Report •


#1
June 22, 2010 at 12:28:54
IF %LC%==1 (GOTO PASSCHK)
ELSE (%LC%==0 GOTO BADLOGIN)
IF %LC%==2 (GOTO PASSCHKX)
ELSE (%LC%==0 GOTO BADLOGIN)

Each ELSE must be on the same line as its IF.

Report •

#2
June 22, 2010 at 13:30:55
IF %LC%==1 (GOTO PASSCHK)
ELSE (%LC%==0 GOTO BADLOGIN)
IF %LC%==2 (GOTO PASSCHKX)
ELSE (%LC%==0 GOTO BADLOGIN)
Each ELSE must be on the same line as its IF.

For clarification, you could code:
IF <something>=<something else> ( <action>
) ELSE (
<some other action>
)

In other words, put the closing IF paren on a new line with
ELSE (
immediately following.

Insomniac at large


Report •

#3
June 22, 2010 at 20:43:01
Thx alot my problem solved :D

Report •

Related Solutions


Ask Question