共用方式為


Item Property (WshUnnamed)

Returns an item using a zero-based index.

                      Object.Item(key)

Parameters

  • Object
    WshUnnamed object.

  • key
    Associated with either a collection or a WshUnnamed object.

Remarks

The Item property returns a string. For collections, it returns an item based on the specified key.

For the unnamed object, items are not named, so you cannot pass the name of the WshUnnamed argument.

The WshUnnamed argument items are stored in the order that they were included on the command line.

When entering the WshUnnamed argument at the command line, you can use blanks in string arguments if you enclose them in quotes.

The quotes are removed in the WshUnnamed collection.

Example

The following example demonstrates how the Item property can be used to return items in the WshUnnamed collection. In this example, two unnamed arguments are supplied to run a script. Inside the script, code causes the unnamed arguments to be output. The Item property is used to index into the unnamed arguments collection.

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

myScript.vbs arg1 arg2

When the following code is executed inside the script:

WScript.Echo WScript.Arguments.Unnamed.Item(0)
WScript.Echo WScript.Arguments.Unnamed.Item(1)

the following output is produced:

arg1
arg2

Applies To:

WshUnnamed Object

See Also

Reference

Arguments Property (WScript Object)

WshUnnamed Object

Count Method (Windows Script Host)

Item Property (WshNamed)

Exists Method (Windows Script Host)