Through his post, Churdoo pointed out that I didn't document what I was doing. (I kind of thought that the structure was easy to understand without additional comments. But here we go:
Of course, you name the file as you like, as long as the extension is .bat.
Menubat.bat
============================
@echo off
REM The previous line turns off echoing of commands.
REM @ in the beginning makes sure this very line won't be echoed, either.
REM 2010-10-29 by TobiF
REM It is possible to set an initial farcomputer
REM as parameter when this batchfile is called.
REM like this: MenuBat FirstComputerName
set farcomputer=%1
REM %1 is a local variable, which expands to the first argument.
REM Here starts the menu.
REM Edit it for the choices you want.
REM You can easily add some lines. It's just text.
:menu
REM the :menu is a label, to allow goto statements
REM to branch execution from here.
REM cls will clear the screen
cls
REM choicecounter is initalized
set choicecounter=0
echo Currently selected computer name is: %farcomputer%
echo.
echo Choose number and press enter
echo.
echo (1) Select other computer. Current is: %farcomputer%
echo (2) Command A
echo (3) Command B
echo (4) Command C
echo (0) Quit
echo.
REM echo. gives a blank line. (Just echo gives another result.)
REM Here starts the choice handling.
REM We won't print the whole menu again if the user
REM enters an invalid choice, since the menu will still
REM remain visible on screen.
REM But if 5 invalid choices are made, then it's
REM time to clear the screen and start over.
:choice
set /P menuchoice=[1,2,3,4,0] ?
REM The text after "=" is simply printed as a prompt.
REM But do edit it to match expected input.
REM start testing input value against options.
REM This section needs to be edited for the options
REM you want to test. More options=additional lines.
REM Feel free to edit the labels further down.
REM In that case they should be changed here, too.
REM Remember that a label can't contain spaces.
if %menuchoice%==1 goto setname
if %menuchoice%==2 goto commanda
if %menuchoice%==3 goto commandb
if %menuchoice%==4 goto commandc
if %menuchoice%==0 goto quit
rem If we end up here, then no choice matched. So: bounce back!
REM Increment choicecounter
Set /A choicecounter+=1
REM Test for more than 5 invalid responses
REM in that case, reprint the whole menu
if %choicecounter% gtr 5 goto menu
REM If we're still here, then iteration is max done 5 times
REM So we can just go back to the input again.
goto choice
REM After the unconditional jump, we're in to
REM our "subroutines"
REM setname is to change the far computer name
:setname
echo.
set /P farcomputer=[Enter name of remote computer: ]?
goto menu
REM Here we execute the first optional command
REM Label (and corresponding goto, higher up)
REM may be changed to make easier to read.
:commanda
echo.
REM next line should be replaced with a real command.
echo this is command A/%farcomputer%
REM do what we need to do
REM In order to see the result of the command
REM before clearing the screen with the menu
REM we pause for the user to hit any key.
pause
goto menu
:commandb
echo.
echo this is command B /%farcomputer%
rem do what we need to do
pause
goto menu
:commandc
echo.
echo this is command C/%farcomputer%
rem do what we need to do
pause
goto menu
REM When user wants to finish, we move execution to
REM the end of the file.
:quit
REM the following echo lines are just
REM placeholders. Not needed at all.
echo.
echo Thanks for your visit. Do come again!
REM Let's clear the variables we've used.
set farcomputer=
set choicecounter=
set menuchoice=
======================================