2 was unexpected at this time batch

Dell / Vostro 1000
May 4, 2010 at 15:11:27
Specs: Microsoft Windows Vista Home Premium, 1.9 GHz / 893 MB
I'm getting this error while trying to write an
interactive batch file. I can't seem to get the
error level configured right the part I'm having
problems with is:

:FEELING determine how subject feels
ECHO. Good...G
ECHO. Bad....B
ECHO.
choice /m "Please choose:" /c:bg /n
ECHO.

::Determine what option was chosen
IF ERROLEVEL 2 GOTO FEELSBAD
IF ERROLEVEL 1 GOTO FEELGOOD

Can you please help?


See More: 2 was unexpected at this time batch

Report •


#1
May 4, 2010 at 15:24:45
What you have works on older model systems, but might not in Vista (i don't have vista), but you might try this variation:
if %errorlevel% equ 2 goto Feelsbad
if %errorlevel% equ 1 goto Feelsgood

note that this version WON'T work on older systems!
or:
if errorlevel==2
(no percentsigns!)
might work, can't test Vista, works on ME.


Report •

#2
May 4, 2010 at 15:34:28
ERROLEVEL
It'd help if you spelled ERRORLEVEL correctly.

Report •

#3
May 4, 2010 at 15:51:29
Thanks I guess it does help to check the spelling huh? It works fine now that it's spelled right. They should make a spell checker for cmd!

Report •

Related Solutions

#4
May 4, 2010 at 17:21:38
@R2, good eye!
zipped right past me...

Report •

Ask Question