WSH » WScript » Arguments

Syntax:
WScript.Arguments

The Arguments collection property is read only and returns the collection of arguments supplied when invoking the current script. The argument list does not include the name of the host executable file (cscript or wscript), or the name of the script being invoked.

Examples

Code:
Set objArgs = WScript.Arguments
WScript.Echo WScript.Arguments.Count
For Each strArg in objArgs
    WScript.Echo strArg
Next
Output:
2
hello
world
Explanation:

This VBScript code illustrates the use of this property when used in a script that is invoked with the command line "cscript test.vbs hello world".

Language(s): VBScript
Code:
objArgs = WScript.Arguments
WScript.Echo(WScript.Arguments.Count());
for (i=0; i<objArgs.length; i++)
{
    WScript.Echo(objArgs(i))
}
Output:
2
hello
world
Explanation:

This JScript code illustrates the use of this property when used in a script that is invoked with the command line "cscript test.vbs hello world".

Language(s): JavaScript