Search code examples
batch-file

How to pass more than 9 parameters to batch file


How can I pass more than nine parameters to bach file.
I tried another SO question How do you utilize more than 9 arguments when calling a label in a CMD batch-script? but not working for me.

I am trying to give the runtime values of a url kept inside batch.
My batch:

start iexplore http://example.com?firstName=%1^&middleName=%2^&lastName=%3^&country=%4^&address=%5^&address2=%6^&address3=%7^&mobileNo=%8^&landlineNo=%9SHIFT SHIFT SHIFT SHIFT SHIFT SHIFT SHIFT SHIFT ^&emailAddress=%1^&hobby1=%2^&hobby2=%3^&hobby3=%4^&hobby4=%5^&hobby5=%6

When using It is taking the previous values of %1, %2, %3,.....etc and the values of 10th,11th,12th.... parameters

Please help !


Solution

  • save the first nine args in a variable. THEN call shift multiple times and only then use the rest:

    set "v=http://example.com?firstName=%1&middleName=%2&lastName=%3&country=%4&address=%5&address2=%6&address3=%7&mobileNo=%8&landlineNo=%9"
    shift
    shift
    shift
    shift
    shift
    shift
    shift
    shift
    shift
    start iexplore %v%&emailAddress=%1&hobby1=%2&hobby2=%3&hobby3=%4&hobby4=%5&hobby5=%6