Batch file menu

I regularly find myself using this batch file template to automate tasks, so I thought I’d share it.


@ECHO off
cls
:beginning
ECHO.
echo **************** Menu *******************
echo.
echo 1 Menu Item A
echo 2 Menu Item B
echo 3 Menu Item C
echo 4 Quit without any action
set choice=
set /p choice=Your choice:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto start
if '%choice%'=='2' goto stop
if '%choice%'=='3' goto restart
if '%choice%'=='4' goto quit
ECHO "%choice%" is not valid please try again
ECHO.
goto beginning
:start
ECHO.
ECHO Menu Item A code goes here
ECHO.
goto beginning
:stop
ECHO.
ECHO Menu Item B code goes here
ECHO.
goto beginning
:restart
ECHO.
ECHO Menu Item C code goes here
ECHO.
goto beginning
:quit
ECHO.
goto end
:end

This entry was posted in Batch Files. Bookmark the permalink.

One Response to Batch file menu

  1. Barry Weymes says:

    Hey – Its good to see your blog actually containing something!

    Powershell is the new Batch…..

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>