1

I have to make batch file, that, when run, will give me options to run Install files. I need to make it multiple choice menu.

I made bit of research and found code, that is multiple choice menu, that asks users input. Forgot link, sorry.

But here is my problem. I want menu to have Check boxes (Tick boxes) that, when ticked install these programs.

Is there any tutorial on how to do it? Or, if that even possible?

DavidPostill
  • 7,734
  • 9
  • 41
  • 60
Vairis
  • 227
  • 3
  • 13
  • 3
    this will be rather be difficult.But you can embed mshta/html pop-ups.Check the examples [here](https://github.com/npocmaka/batch.scripts/tree/master/hybrids/mshta/ui.extensions) to learn the technique.Creating choose menu in html is easy , you only need to decide how you'll parse the data. – npocmaka Jul 22 '16 at 08:18

2 Answers2

2

It's not clickable, but this could be what you want:

@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%

Put the installing logic where echo executing %install% is, for example if "%install%"=="1" start "" "somefileToInstall"

Dennis van Gils
  • 3,487
  • 2
  • 14
  • 35
1

DOS Batch - Menus is a good tutorial that you can create an advanced dynamic menu

Those are some examples where i learned from it to create easily a menu like that :

Sound in batch?

How to check and correct user input when he omit the extension .exe to kill the process?

Community
  • 1
  • 1
Hackoo
  • 18,337
  • 3
  • 40
  • 70