Question

I am learning how to write batch files for Windows 7 using the VBScript like native scripting language.

I suppose I am not using the Windows Scripting Host or the Power Shell. I am using the simple old style VBScript like syntax.

I don't understand how to shift arguments when there are more than 9 arguments (or 10 including the name of the batch file) passed to the batch file.

Could you please teach me that?

Let us assume that you called my batch file with the following arguments:

C:\>call my.bat "one" "two" "three" "four" 
    "five" "six" "seven" "eight" "nine" "ten" "eleven"

How would you access the arguments ten and eleven from within my.bat?

Was it helpful?

Solution

this is the batch taken from ss64.com

@echo off
:start
if "%1"=="" (goto :exit)
:: Do whatever with token %1
Echo [%1] 
:: Shift %2 into %1 
SHIFT
goto :start

:exit
::pause

call that batch with more than 10 arguments, it will display all

    shift.bat 1 2 3 4 5 6 7 8 9 10 11
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top