How can I pass gui batch arguments in Windows XP/7?
Is there any straightforward way to call a .bat file and have it prompt me for each of the arguments that will replace the %1 %2 and so forth fields? I can memorize their order just fine and run it from the command line, but it would be preferable for friends & family if there was an icon they could just click and get the appropriate prompts.
@echo off
echo "Parameter 1"
set /p p1=
echo "Parameter 2"
set /p p2=
[...]
yourcommand.exe %p1% %p2% [...]
@echo off
stops commands being printed. We will ask for a parameter each using echo
, set /p p1=
asks the user for some input (use "return" or "enter" to confirm) and stores it into variable %p1%
. In the last line you can call your program with the parameters entered.
You can ask the user for parameters with set /p
.
Optionally, you can check if %1
exists first. e.g. with if "%1"==""
or something similar.