Home NT WSH
WshScript.Arguments

Return command-line parameters

Syntax 
       WScript.Arguments

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

Example Script

'Set a reference to the arguments
Set objArgs = Wscript.Arguments

'Count the arguments
WScript.Echo objArgs.Count

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

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

'Display just the third parameter
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 commands
:

WshShell.Shortcut.Arguments

Equivalent Windows NT command:

Parameters - Command Line Parameters



Back to the Top

Simon Sheppard
SS64.com