some commands which can be usefull (type them in dos with /? behind them and you'll see the explainations):
set /?
shift /?
if /?
goto /?
for /?
It is far too extensive to explain everything you can do with command lines and/or variables in DOS (it is almost a whole programming language on it's own now). Best is to google for a page which explains some stuff and work from there.
EDIT: but I'll make some quick examples anyways:
In all examples:
- They all can take a number as command line. If a number is given, the prompt will not be executed. eg:
C:\> example1.bat<enter>
Choose a number: 1234<enter>
net send abc1234 Hello
C:\> example1.bat 5678<enter>
net send abc5678 Hello
C:\> _
- No 'advanced' checking is done on the validity of the numbers; the user can enter letters as well for example.
- Remove the 'echo' from the line "echo net send" if you actually want the net send command to be executed. 'echo' is added in these examples so you can clearly see what is suppose to be executed. (don't remove "@echo off" though)
First example:
@echo off
if "%1"=="" (
set /p choice=Choose a number:
) else (
set choice=%1
)
echo net send abc%choice% Hello
set choice=
Second example:
- shorter example of the first
@echo off
set choice=%1
if "%choice%"=="" set /p choice=Choose a number:
echo net send abc%choice% Hello
set choice=
Third example:
- variant of the second example:
- if user didn't type a number the question is asked again
@echo off
set choice=%1
:CheckNumber
if "%choice%"=="" set /p choice=Choose a number:
if "%choice%"=="" goto CheckNumber
echo net send abc%choice% Hello
set choice=
Fourth example:
- other version of the third example
@echo off
set choice=%1
:CheckNumber
if "%choice%"=="" (
set /p choice=Choose a number:
goto CheckNumber
)
echo net send abc%choice% Hello
set choice=
Fifth example:
- the program will quit when enter is pressed without typing a number
@echo off
set choice=%1
if "%choice%"=="" set /p choice=Choose a number:
if not "%choice%"=="" echo net send abc%choice% Hello
set choice=