0

So I just got into batch and I wanted to create a list where a person could choose which option to view.

Down below is what I've done so far and obviously didn't work.

What I really hate is that pressing 1 to access the first menu and then again 1 to access the other one totally works, but if you try going back and press 2 it just closes.

I should mention I wanted to add an option in all of the categories to press 1 and it brings you back, in the main menu 5 stands for leave.

Hope you guys can understand the issue. Thanks.

@ Echo off
:a
echo Welcome. Please select the needed option to continue.
ECHO 1. 
ECHO 2. 
ECHO 3. 
ECHO 4. 
ECHO 5. 
set /p menu=
if %menu%==1 (
    :b
    ECHO 1.
    ECHO 2.
    ECHO 3.
    ECHO 4. 
    ECHO 5. 
    ECHO 6. 
    ECHO 7. Go Back
    set /p menu1=
)
if %menu1%==1 (
    ECHO 1
    set /p I=
)
    if %I%==1 (
    goto b
)
if %menu1%==2 (
    ECHO 2
    set /p II=
)
if %II%==1 (
    goto b
)
if %menu1%==3 (
    set /p III=
    ECHO 3
    if %III%==1 (
        goto b
    )
)
if %menu1%==4 (
    set /p IV=
    ECHO 4
    if %IV%==1 (
        goto b
    )
)
if %menu1%==5 (
    set /p V=
    ECHO 5
    if %V%==1 (
        goto b
    )
)
if %menu1%==6 (
    set /p VI=
    ECHO 6
    if %VI%==1 (
        goto b
    )
)
if %menu1%==7 (
    goto a
)
)
if %menu%==2 (
    ECHO 1.2
    set /p menu2=
)
if %menu2%==1 (
    goto a
)
)
if %menu%==3 (
    set /p menu3=
    ECHO 1.3
    if %menu3%==1 (
        goto a
    )
)
if %menu%==4 (
    set /p menu4=
    ECHO 1.4
    if %menu4%==1 (
        goto a
    )
)
if %menu%==5 (
    ECHO Logging Off...
    clr
)
Compo
  • 36,585
  • 5
  • 27
  • 39
  • 1
    Does this answer your question? [Multiple choices menu on batch file?](https://stackoverflow.com/questions/14529246/multiple-choices-menu-on-batch-file) Also see https://stackoverflow.com/q/38651627/62576 – Ken White Mar 21 '20 at 23:40
  • I have formatted your code properly, the first line was missing! Whilst I was doing that, I took the liberty of indenting it, to help with its readability. This also clearly highlights errors with unbalanced parentheses. Please fix those, but then take a look at what you have left because the are other errors too. You cannot have labels within code blocks, and there's no such command as `clr`. – Compo Mar 21 '20 at 23:40
  • Choice is the command of choice for menu selection (pardon the pun). [See here for a tutorial](https://www.youtube.com/watch?v=kMdWA-DR27s) – T3RR0R Mar 22 '20 at 07:33

0 Answers0