Jump to content

Recommended Posts

I dunno why,

but i've made this lil batch progr,

and it keeps telling me that their is a syntax error but I can't find it...

 

:: SSA-FILES
:: Made By BIA II
@ECHO OFF
:begin
title ~SSA-FILES~
SET /P pass=password:
IF "%pass%"=="1234"
GOTO accept
ELSE
GOTO sec

:sec
set /P pass=password
IF NOT '%pass%'=='abcd'
GOTO loop
ELSE
GOTO accept

:loop
start C:\Windows
GOTO loop

:accept
CLS
echo Logged in succesfull.
pause
CLS
echo ~M~embers
echo ~O~bjects
echo ~Q~uit
SET /P Option=Choose your option
IF '%Option%'=='M'
GOTO Members
ELSE IF '%Option%'=='O'
GOTO Objects
ELSE IF '%Option%'=='Q'
GOTO Quit
Else
GOTO accept

:Members
CLS
echo #Members = 4
echo.
echo 1: BIA I
echo 2: BIA II
echo 3: SSA III
echo 4: SSA IV
echo 5: Back
SET /P Members=Choose a number:
IF '%Members%'=='1'
GOTO BIAI
ELSE IF '%Members%'=='2'
GOTO BIAII
ELSE IF '%Members%'=='3'
GOTO SSAIII
ELSE IF '%Members%'=='4'
GOTO SSAIV
ELSE IF '%Members%'=='5'
GOTO accept
ELSE
GOTO Members

:BIAI
echo name:   Thomas Van Breusegem
echo Rank:   BIA
echo SSA#:   I
echo Status: Active 
pause
GOTO Members

:BIAII
echo Name:   Darragh Van Tichelen
echo Rank:   BIA
echo SSA#:   II
echo Status: active
pause
GOTO Members

:SSAIII
echo Name:   Annelies Blondé
echo Rank:   None
echo SSA#:   III
echo Status: Unknown
pause
GOTO Members

:SSAIV
echo Name:   Laure Oomens
echo Rank:   None
echo SSA#:   IV
echo Status: Unknown
pause
GOTO Members

:Objects
echo Currently not avaible
pause
GOTO accept

:Quit
echo Goodbye
pause
exit

Link to comment
https://forums.phpfreaks.com/topic/157965-batch-problem/
Share on other sites

  • 2 months later...

Honestly, I've looked at your file here for the last two days trying to puzzle out why I was getting that syntax error as well.  I've finally figured it out, so here's a working version of your file:

 

:: SSA-FILES
:: Made By BIA II
:: Corrected by captbeagle
@ECHO OFF
:begin
title ~SSA-FILES~
SET /P pass=password: 
IF "%pass%"=="1234" GOTO accept 
GOTO sec

:sec
set /P pass=password2:
IF NOT "%pass%"=="abcd" GOTO loop
GOTO accept

:loop
start C:\Windows
::Not sure why this is set to loop. It could get pretty annoying, so I put in a pause.
PAUSE
GOTO loop

:accept
CLS
echo Logged in succesfully.
pause
CLS

echo ~M~embers
echo ~O~bjects
echo ~Q~uit

SET /P Option=Choose your option:

IF "%Option%"=="M" GOTO Members
IF "%Option%"=="O" GOTO Objects
IF "%Option%"=="Q" GOTO Quit
::If all the above fail the condition, it will execute the following line
GOTO accept

:Members
CLS
echo #Members = 4
echo.
echo 1: BIA I
echo 2: BIA II
echo 3: SSA III
echo 4: SSA IV
echo 5: Back
SET /P Members=Choose a number:
:: GOTO must be on same line
IF "%Members%"=="1" GOTO BIAI
:: I could never get an ELSE to parse properly
IF "%Members%"=="2" GOTO BIAII
IF "%Members%"=="3" GOTO SSAIII
IF "%Members%"=="4" GOTO SSAIV
IF "%Members%"=="5" GOTO accept
::ELSE
GOTO Members

:BIAI
echo name:   Thomas Van Breusegem
echo Rank:   BIA
echo SSA#:   I
echo Status: Active 
pause
GOTO Members

:BIAII
echo Name:   Darragh Van Tichelen
echo Rank:   BIA
echo SSA#:   II
echo Status: active
pause
GOTO Members

:SSAIII
echo Name:   Annelies Blondé
echo Rank:   None
echo SSA#:   III
echo Status: Unknown
pause
GOTO Members

:SSAIV
echo Name:   Laure Oomens
echo Rank:   None
echo SSA#:   IV
echo Status: Unknown
pause
GOTO Members

:Objects
echo Currently not avaible
pause
GOTO accept

:Quit
echo Goodbye
pause
exit

 

Now, for the differences and what I've discovered:

 

  • Sometimes you used single quotes instead of double quotes around variables and strings.  They must always be double quotes, even if both sides are using the same thing (label sec)
  • You always put the GOTO on the next line.  It must always be on the same line as the beginning of the IF statement.  That's what caused most of the syntax errors I saw, once I discovered the cause.
  • I never could get an ELSE to work.  I don't know if that's an OS thing or if I always did it wrong, but I found that if I just put the action to do in place of the else on the next line, it'd work just as well, though that could look a little messy.
  • Unrelated to fixing the file, but it's not a fun idea to open a folder in Explorer within a loop.  I put a pause in that section.

 

See if you can get that working on your end.  I've been through every option on my computer and it's working fine, but I read in some documentation that some of the commands throw different results depending on which version of Windows you're running.  I tried to stick to the generic stuff that seemed compatible with every version.

Link to comment
https://forums.phpfreaks.com/topic/157965-batch-problem/#findComment-883015
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.