WScript.Arguments

Return command-line parameters.

Syntax 
       WScript.Arguments

       WScript.Arguments(n)

       WScript.Arguments.item(n)

   n  = Return the single argument n
        counting from 0

To pass named arguments use:

       WScript.Arguments.named

In addition to the argument itself : MyObject.item(I)you can also retrieve a count or length:
MyObject.Count
MyObject.Length

The default property is .item

Examples

C:> cscript demo.vbs arg1 value2 33 456 "Last Arg"

[demo.vbs]
' Store the arguments in a variable:
Set objArgs = Wscript.Arguments

'Count the arguments
WScript.Echo objArgs.Count

' Display all command-line arguments
For Each strArg in objArgs
  WScript.Echo strArg
Next

' Display the first 3 command-line arguments
For I = 0 to 2
  Wscript.Echo objArgs(I)
Next

'Display just the third argument
Wscript.Echo objArgs(2)

'Or without the reference
WScript.Echo "The third argument is", WScript.Arguments(2)

Rule #1: Don't sweat the small stuff.
Rule #2: It's all small stuff - Dr Robert S Eliot, University of Nebraska cardiologist


Related:

Agruments - Command Line arguments
.Shortcut.Arguments
Equivalent Windows CMD command: Parameters - Command Line Parameters


© Copyright SS64.com 1999-2014
Some rights reserved