有没有办法为批处理文件创建Tick菜单

时间:2016-07-22 08:15:09

标签: batch-file

我必须制作批处理文件,在运行时,它会为我提供运行安装文件的选项。我需要做多选菜单。

我做了一些研究,找到了代码,即多选菜单,要求用户输入。忘了链接,抱歉。

但这是我的问题。我希望菜单中有复选框(勾选框),当勾选安装这些程序时。

有没有关于如何做的教程?或者,如果可能的话?

2 个答案:

答案 0 :(得分:2)

它不可点击,但这可能是你想要的:

CountryResource

将安装逻辑放在@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% 所在的位置,例如echo executing %install%

答案 1 :(得分:1)

DOS Batch - Menus 是一个很好的教程,可以创建高级动态菜单

这些是我从中学到的一些例子,可以轻松创建这样的菜单:

Sound in batch?

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