0

I was wondering if I could get some help with regards to writing a batch file that could take user input. (Or guidance if a batch file is not the way to go.)

I usually have a task that I do by opening CMD, navigating to a specific folder and running the following command

rda -v 848 -i "C:\me\rda-tools-1.7.0.Ra1\Input" -o "C:\me\rda-tools-1.7.0.RC1\Output"

Now this task is repetitive, and the only thing that changes each time is the number (848 in my example).

Can you guide me on how to write a batch file that navigates to the specific folder, asks me for that 3 digit number for input and then runs the command above?

Please note I have very little knowledge on batch files. Thanks.

HosseinK
  • 1,247
  • 4
  • 13
  • 18

2 Answers2

2

You can pass parameter to a batch file. Follow below article on how to pass parameter to a batch file How do I pass command line parameters to a batch file?

Community
  • 1
  • 1
Praveen
  • 21
  • 1
0

You can pass parameters to a batch file. They're taken in sequence, from %1 to %9 (you can use more, but you have to shift them to get them into position to use). (Technically, there is a %0 - it's the full path and filename of the batch file itself.)

For example, put the following into a batch file (for instance, RunRDA.bat):

@echo off
rda -v %1 -i "C:\me\rda-tools-1.7.0.Ra1\Input" -o "C:\me\rda-tools-1.7.0.RC1\Output"

Run it from a command prompt with your version:

C:\RDA>RunRDA 848

For more information, see How to pass command line parameters to a batch file?

Community
  • 1
  • 1
Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Nice just tried it. However, this means i have to navigate to C:\RDA every time i want to do this. Is there a way to be able to have a batch file, double click it, be asked the 3 digit number and run the command? (i.e. no navigation) EDIT- don't mean to sound lazy, just want to involve the least amount of manual steps as possible. – HosseinK Apr 08 '15 at 20:17
  • That's not the question you asked here. :-) Your question was about passing parameters to a batch file from the command line, which was the question I answered. If you now have a different question about how to get a prompt for information from a batch file, first search to see if that's been asked here before; if not, post a new question asking about that topic. – Ken White Apr 08 '15 at 20:22
  • Of course, thank you for the help Ken. Wasn't aware follow up questions should be created as new threads. Will do! – HosseinK Apr 08 '15 at 20:26