♦ Simple menu
This is a simple menu where you are given choices, but you must type in the exact choices. If you don't you will get a syntax error. It is a very simple menu which will output exactly what you selected. It doesn't have any looping structure.
@echo off
:start
echo -1 (Message 1)
echo -2 (Message 2)
echo -3 (exit)
echo.
set /p Program= Please make a selection.:
goto %Program%
:1
echo Message 1 was selected
goto start
:2
echo Message 2 was selected
goto start
:3
exit
♦ Menus using if and else if statements.
These menus use if and else statements which will use a looping structure. If you select the wrong thing, it will simply loop you back into the program again. The program can execute the right selection, and loop back into the beginning of the program until you select the exit selection in the first example. The 2nd example doesn't give you any way to exit the program, so it will give you selections infinitely.
@echo off
echo - 0 (Selection 1)
echo - 1 (Selection 2)
echo - 2 (Selection 3)
echo - 3 (EXIT PROGRAM)
echo.
:start
set /p Entry=Please make a selection and press enter to continue.
if %Entry% LEQ 2 (
goto Part_%Entry%
) else (
goto start
)
:Part_0
echo You selected 1
goto start
:Part_1
echo You selected 2
goto start
:Part_2
echo You selected 3
goto start
:Part_3
exit
Another selection menu with else if statements
@echo off
echo - Select A (Message)
echo - Select B (Message 2)
echo - Select C (Message 3)
echo.
:begin
set /p Select=Please make a selection and press enter to continue
if %Select% EQU A (
goto Part_A
) else if %Select% EQU B (
goto Part_B
) else if %Select% EQU C (
goto Part_C
) else (
goto begin
)
:Part_A
Echo You selected Message
goto begin
:Part_B
Echo You selected Message 2
goto begin
:Part_C
Echo You selected Message 3
goto begin
References
Batch Programming Inputs and Outputs
• Batch Programming Inputs and Outputs
Opening Up Programs with Batch Files
• Opening Up Programs with Batch Files
Batch Program Multi Menu
• Batch Program Multi Menu
How to Create a Basic FTP Batch File
• How to Create a Basic FTP Batch File
FTP Console Commands How to Send and Retrieve Files
• FTP Console Commands How to Send and ...
FTP Command Prompt Connecting and Downloading Files
• FTP Command Prompt Connecting and Dow...
Run a Batch File in Administrative Mode with Task Scheduler
• Run a Batch File in Administrative Mo...
Create a Batch File for Ipconfig
• Create a Batch File for Ipconfig
Basic Batch Commands Reference Guide
• Basic Batch Commands Reference Guide
Creating a Batch File to Remove Directories and Subdirectories
• Creating a Batch File to Remove Direc...
Batch file to Open Applications
• Batch file to Open Applications
Creating a Batch File to Copy All Subdirectories onto Another Folder
• Creating a Batch File to Copy All Sub...
Creating a Batch File to Open Folders on Windows Desktop
• Creating a Batch File to Open Folders...
Creating a Batch File to Delete Folders and Remove Directories
• Creating a Batch File to Delete Folde...
Creating a Batch File to send files from a Local Drive to a Network Drive
• Creating a Batch File to send files f...
Creating a Batch File to Copy Files in a Local Drive
• Creating a Batch File to Copy Files i...
Open Websites and Folders with Batch file
• Open Websites and Folders with Batch ...
Batch Programming Mathematical Functions
• Batch Programming Mathematical Functions
Batch Programming Menu with If statements
• Batch Programming Menu with If statem...