Windows Script Host  

<named> Element

Describes a named argument for the script.

<named
   name = namedname
   helpstring = helpstring
   type = "string|boolean|simple"
   required = boolean
/>

Arguments

name
String that represents the name of the argument you are describing. Defines the argument at the command line and in the script.
helpstring
String that represents the help description for the argument. The WSH runtime provides the help description using the ShowUsage method or the /? argument.
type
Optional. Describes the type of argument, which defines how the argument will be parsed from the command line. The default value is simple.
required
Optional. A Boolean value that indicates whether an argument is required or not. Affects the display of the usage only.

Remarks

The <named> element is contained by (enclosed within) a set of runtime tags.

An argument with the name server would provide a /server argument at the command line as well as an argument named server in the WSHNamed arguments collection.

If the type is string, the argument is a string. The argument is passed to the script as /named:stringvalue.

If the type is Boolean, the argument is Boolean. The argument is passed to the script as /named+ to turn it on, or /named- to turn it off.

If the type is simple, the argument takes no additional value and is passed as just the name, /named.

Example

The following script demonstrates the use of the <named> Element:

<job>
<runtime>
  <named
    name="server"
    helpstring="Server to access"
    type="string"
    required="true"
  />
  <named
    name="user"
    helpstring="User account to use on server. Default is current account."
    type="string"
    required="false"
  />
  <named
    name="enable"
    helpstring="If true (+), enables the action. A minus(-) disables."
    type="boolean"
    required="true"
  />
  <named
    name="verbose"
    helpstring="If specified, output will be verbose."
    type="boolean"
    required="false"
  />
</runtime>
<script language="JScript">
  WScript.Arguments.ShowUsage();
</script>
</job>

This will produce the following output when usage is shown:

Usage: example.wsf /server:value [/user:value] /enable[+|-] [/verbose]

Options:

server    : Server to access
user      : User account to use on server. Default is current account.
enable    : If true (+), enables the action. A minus(-) disables.
verbose   : If specified, output will be verbose.

See also

ShowUsage Method | <runtime> Element | <unnamed> Element | <description> Element | <example> Element