Execute certain menu options chosen by the user in batch

July 11, 2012 at 07:33:10
Specs: Windows XP
Hey guys,

I have this menu in batch script:

1 - A
2 - B
3 - C
4 - D
5 - runAll
6 - Quit

Right now, what I do with it is if the user enter 1, then it runs the 1st one and loops back to the menu, 2 for the 2nd, etc. If the user enters 5 then my script goes and runs 1 through 4 step by step in order.
My question is: "Is it possible to run/execute certain ones that you choose to execute?" Let's say I want to execute 1 & 4 and loop back to the main menu. I enter "1(space)4" and the script takes those arguments/parameters and goes and finds the corresponding option and executes it. Does it make sense? Is it possible?

I do have the option of running each one of those options separately, but this idea, the one I'm talking about, makes it more efficient and faster.

See More: Execute certain menu options chosen by the user in batch

Report •

July 11, 2012 at 10:01:21
Basically like this:

@echo off
echo 1-option1
echo 2-option2
set /p "opts=enter options"
for %%i in (%opts%) do goto :opt%%i
goto :eof
goto :eof
goto :eof


Report •

July 13, 2012 at 05:22:52
Should probably call :opt%%i.

How To Ask Questions The Smart Way

Report •

July 13, 2012 at 09:23:25
Yeah I had call originally but can't remember why I changed it.


Report •
Related Solutions

Ask Question