Windows Script Host  

Item Property (WshNamed)

Provides access to the items in the WshNamed object.

Object.Item(key)

Parameters

Object
WshNamed object
key
The name of the item you want to retrieve.

Remarks

The Item property returns a string. For collections, it returns an item based on the specified key. When entering the arguments at the command line, you can use blanks in string arguments if you enclose the string in quotes. Consider the following example:
myscript.vbs /stringarg:"This string has spaces"

The quotes will be removed in the WshNamed collection. For an argument to be in the WshNamed collection, it must have been used on the command line. If the argument has no value (such as a simple argument or an empty string), the Item property returns an empty string. Requesting a non-existent named argument from the Item property causes an error. To check if an argument exists, use the Exists method.

Example 1

In the following example, two named arguments are supplied to run a script. Inside the script, code causes the named arguments to be output. The Item property is used to index into the named arguments collection.

The following line is typed at the command prompt to run the script.

myScript.vbs /c:arg1 /d:arg2

If the following code is executed inside the script:

WScript.Echo WScript.Arguments.Named.Item("c")
WScript.Echo WScript.Arguments.Named.Item("d")

then the following output is produced:

arg1
arg2

See Also

WshNamed Object | WshUnnamed Object | Count Method | Item Property | Exists Method