Menu to sub menu selection

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Menu to sub menu selection

#1 Post by Mahendra » 23 Sep 2012 02:53

i am able to create a menu for selection of items. The menu items created based on the output of the command and output may not be same always. i want to select the items from that menu.

@echo off
setlocal enabledelayedexpansion

set c=0
for /f "tokens=2 delims=' '" %%m in ('runmqakm -cert -list all -db abc.db -pw passwd') do (
set /a c=c+1
echo !c!.%%m
)
set /p input= enter your input :

The output will be like this

1. test1
2. test2 cert
3. versign cert
4.
5.
enter your input :

The user can select 0-100(any) ,...suppose the user select option 2. The associate value test2 cert as label for another command to execute
for /f "tokens=2 delims=' '" %%m in ('runmqakm -cert -details -%label% -db abc.db -pw passwd') do echo %%m

i am unable to catch associated option value to execute another command. can some one guide me on this.?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Menu to sub menu selection

#2 Post by foxidrive » 23 Sep 2012 03:20

Here is one way.

Code: Select all

@echo off
setlocal enabledelayedexpansion
set c=0
for /f "tokens=2 delims=' '" %%m in ('runmqakm -cert -list all -db abc.db -pw passwd') do (
set /a c=c+1
set [!c!]=%%m
)
set [
set /p input= enter your input :
echo ![%input%]!
pause

Post Reply