共用方式為


Exists Method (Windows Script Host)

 

Indicates whether a specific key value exists in the WshNamed object.

Syntax

object.Exists(key)

Parameters

  • object
    WshNamed object.

  • Key
    String value indicating an argument of the WshNamed object.

Remarks

The Exists method returns a Boolean value. It returns true if the requested argument was specified on the command line (otherwise, it returns false).

Legacy Code Example

Consider the following information typed at the command line.

cscript myScript.vbs /c:"WSH is a wonderful thing"

You could use these two lines of Visual Basic Scripting Edition (VBScript) code to determine whether the following command line switches were used to start the script.

WScript.Echo WScript.Arguments.Named.Exists("C")
WScript.Echo WScript.Arguments.Named.Exists("D")

Applies To:

WshNamed Object

Change History

Date

History

Reason

September 2010

Modified the example.

Content bug fix.

See Also

Arguments Property (WScript Object)
WshUnnamed Object
Count Method (Windows Script Host)
Item Property (WshNamed)