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
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)
“Always remember that your calmness under fire is your best defense in any argument or discussion” ~ Robert Greene
Related:
HowTo: Arguments - Command Line arguments.
.Shortcut.Arguments.
Equivalent Windows CMD command: Parameters - Command Line Parameters.