1

I created a simple menu of choices of numbers like the following:

@echo off
CLS
:MENU
ECHO.
ECHO ...............................................
ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT.
ECHO ...............................................
ECHO.
ECHO 1 - Open MSOFFICE 2007
ECHO 2 - Open MSOFFICE 2010

CHOICE /N /T 10 /D 1 /C 12 /M "Press 1 for MSOFFICE 2007 or 2 for MSOFFICE2010 
Default is 1"
IF ERRORLEVEL==1 GOTO OFFICE2007
IF ERRORLEVEL==2 GOTO OFFICE2010

:OFFICE2010
C:\MSOFFICE2010.TXT

:OFFICE2007
C:\MSOFFICE2007.TXT

My problem is that when I press choice "2" it opens the file of choice "1"

What I am doing wrong?

1 Answers1

0

You forgot to add "%" before and after ERRORLEVEL:

IF %ERRORLEVEL%==1 GOTO OFFICE2007 etc...

And you need to add goto :EOF in your OFFICE2010 section, otherwise you will execute both files.

:OFFICE2010
C:\MSOFFICE2010.TXT
goto :EOF

:OFFICE2007
C:\MSOFFICE2007.TXT
Swisstone
  • 6,725
  • 7
  • 22
  • 32