How to run Installer through Batch Multiselect menu

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vairiks123
Posts: 6
Joined: 24 Jul 2016 08:49

How to run Installer through Batch Multiselect menu

#1 Post by vairiks123 » 24 Jul 2016 09:02

Hello!
Guy from another forum shared his Multiple Select menu in batch file. Unfortunately, this is my first time creating Batch scripts so I wanted to ask for your help.

Here is Menu:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set "getKeyMacro=powershell -noprofile "^
    while (-not (37..40+13).contains($x)) {^
        $x = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown').VirtualKeyCode^
    }^
    if ($x -eq 13) {^
    'enter'^
    }^
    ('left','up','right','down')[$x - 37]^
""

set "num=0"
for %%a in ("Install thing 1"
            "Do thing 2"
            "Execute thing 3"
            "Run thing 4"
            "Test thing 5") do (
   set /A num+=1
   set "option!num!=0"
   set "option!num!name=%%~a"
)
set "maxOptions=%num%"
set "selected=1"
:select
cls
echo use ^<right^> arrow to continue, ^<up^> and ^<down^> to select, and ^<enter^> to toggle
FOR /L %%G IN (1,1,%maxOptions%) DO (
set "display=[ ]"
if !option%%G! equ 1 set "display=[x]"
if %%G equ !selected! set "display=^>!display!"
echo !display! !option%%Gname!
)
FOR /F "delims==" %%G IN ('%getKeyMacro%') DO set "key=%%G"
if "%key%"=="up" set /a "selected-=1"
if "%key%"=="down" set /a "selected+=1"
if %selected% lss 1 set "selected=1"
if %selected% gtr %maxOptions% set "selected=!%maxOptions%!"
if "%key%"=="enter" goto toggle
if "%key%"=="right" goto OK
goto select

:toggle
set /a "option%selected%+=1"
set /a "option%selected%=!option%selected%!%%2"
goto select

:OK
FOR /L %%G IN (1,1,%maxOptions%) DO (
if !option%%G! equ 1 (
call :logic "%%G"
)
)
pause

goto :eof
:logic
set "install=%~1"
echo executing %install%


So my problem is - How do I assign Installers to the menu?

Thank you very much for any help.
Last edited by vairiks123 on 24 Jul 2016 09:20, edited 1 time in total.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to run Installer through Batch Multiselect menu

#2 Post by aGerman » 24 Jul 2016 09:17

In that part of the code you can change the menu items:

Code: Select all

for %%a in ("Install thing 1"
            "Do thing 2"
            "Execute thing 3"
            "Run thing 4"
            "Test thing 5") do (

In label :logic you have to place some IF statements. %~1 contains the number of the selected item.

Regards
aGerman

vairiks123
Posts: 6
Joined: 24 Jul 2016 08:49

Re: How to run Installer through Batch Multiselect menu

#3 Post by vairiks123 » 24 Jul 2016 09:19

aGerman wrote:In that part of the code you can change the menu items:

Code: Select all

for %%a in ("Install thing 1"
            "Do thing 2"
            "Execute thing 3"
            "Run thing 4"
            "Test thing 5") do (

In label :logic you have to place some IF statements. %~1 contains the number of the selected item.

Regards
aGerman


I don't know how to even thank you!

Thank you VERY much.

Regards,
Vairis

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

Re: How to run Installer through Batch Multiselect menu

#4 Post by foxidrive » 25 Jul 2016 20:39

vairiks123 wrote:I don't know how to even thank you!

Thank you VERY much.

Regards,
Vairis


If you still need some help then try using google to translate your question to English from your native language.

Write about how you need to use your menu, so the programmers here can understand your task.

Post Reply