Martin M
Martin M

Reputation: 51

executing multiple commands batch file

I would like to build script to chose commands to run but then they should run in a specific order which was set at the beginning by user. for example:

:MENU
ECHO.

SET /P M=Type 1, 2, 3, 4 or 5 then press ENTER:
IF %M%==1 GOTO 1
IF %M%==2 GOTO 2
IF %M%==3 GOTO 3
IF %M%==4 GOTO 4
IF %M%==5 GOTO 5

:1
GOTO MENU

:2
GOTO MENU

:3
GOTO MENU

:4
GOTO MENU

:5
EXIT

For example in this scenario when I am prompt to choose 1, 2, 3, 4 or 5 I would like to execute command: 1, 2, 4 then display MENU. So I simply type 1, 2, 4 on the screen and then batch will execute it - Commands should follow order 1 then 2 then 4

The other example would be 1, 3, 2, 4 etc.

is this possible? :)

Upvotes: 3

Views: 865

Answers (1)

npocmaka
npocmaka

Reputation: 57302

:MENU
ECHO.

SET /P M=Type 1, 2, 3, 4 or 5 then press ENTER:


for %%C in (%M%) do (
 call :%%C
)
goto :MENU    

:1
GOTO :EOF

:2
GOTO :EOF

:3
GOTO :EOF

:4
GOTO :EOF

:5
EXIT

I'm not absolutely sure if this is what you looking for..

Upvotes: 3

Related Questions