this one's a bit difficult to explain, but I'll do my best.
I'm passing a list of directories into a batch file via a string array, which is created in Java and then passed into the .bat using Runtime.getRuntime().exec(commands). The trouble I am having is in regards to accessing the commands array, the size of which may vary from execution to execution. For example, during one run, "Commands" may contain the following:
{"cmd.exe", "/C", "Start", "program.bat", "stringA", "stringB", "stringC"}
The first four elements are used to call the batch file, so only strings A, B, and C are passed into the batch file (program.bat) as parameters. However, on the next run, "commands" may look like this:
{"cmd.exe", "/C", "Start", "program.bat", "stringA", "stringB", "stringC", stringD, stringE}
As you can see, there are two more strings added to the parameters list. My question is this: In my batch file I have this:
::Get stringA (param 1)
set stringA=%1
::Get stringB (param 2)
set stringB=%2
::Get stringC (param 3)
set stringC=%3
This takes the three string parameters (from the first "commands" array) and sets local variables to whatever values are passed in to the corresponding parameters. I am wondering if there is a way to determine the number of parameters (from the second "commands" array, for example) from within the batch file, and set/create the proper number of local variables accordingly. I focus primarily on Java, so batch files are still fairly new to me. Any suggestions will be very much appreciated, as I've been trying to figure this one out for a while on my own with no success.