Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted
@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.

share|improve this answer
    
Could you provide some explanation about what your code does? Especially the set statements. –  Tom Wijsman Oct 31 '11 at 13:18
    
set just asks for some input and stores it into a variable. –  Jens Erat Oct 31 '11 at 15:46
    
As a note, at least for some versions of windows (I haven't tested) the set commands can be simplified to set /p pn="Parameter n: " –  Russell S. Pierce Mar 23 '12 at 15:31
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.