@if(@CodeSection==@Batch)@then@echo off
setlocal EnableDelayedExpansion
rem Multi-line menu withoptions selection via DOSKEY
rem AntonioPerezAyala
rem Define the options
set numOpts=0for%%a in (FirstSecondThirdFourthFifth)do(
set /A numOpts+=1
set "option[!numOpts!]=%%a Option")
set /A numOpts+=1
set "option[!numOpts!]=exit"
rem Clear previous doskey history
doskey /REINSTALL
rem Fill doskey history withmenu options
cscript //nologo /E:JScript "%~F0" EnterOptsfor/L%%i in (1,1,%numOpts%)do set /P"var=":nextOpt
cls
echo MULTI-LINEMENUWITHOPTIONSSELECTION
echo/
rem Send a F7 key toopenthe selection menu
cscript //nologo /E:JScript "%~F0"
set /P"var=Select the desired option: "
echo/if"%var%" equ "exit"goto:EOF
echo Option selected:"%var%"
pause
goto nextOpt
@endvar wshShell =WScript.CreateObject("WScript.Shell"),
envVar =wshShell.Environment("Process"),
numOpts =parseInt(envVar("numOpts"));if(WScript.Arguments.Length){// Enter menu optionsfor(var i=1; i <= numOpts; i++){wshShell.SendKeys(envVar("option["+i+"]")+"{ENTER}");}}else{// Enter a F7 to open the menuwshShell.SendKeys("{F7}");}