<unnamed> Element

Describes an unnamed argument for the script.

                      <unnamed 
   name       = unnamedname
   helpstring = helpstring
   many       = boolean
   required   = boolean or integer
/>

Arguments

  • name
    The string that is used in the usage to represent this argument. This value is not used elsewhere.

  • helpstring
    String that represents the help description for the argument. The WSH runtime provides the help description using the ShowUsage method or the /? argument.

  • many
    Optional. Boolean value. If true, then this argument may be repeated more times than specified by the required attribute. Otherwise, the required attribute represents the exact number of the argument that is required. See the example below for more details.

  • required
    Optional. An integer value indicating how many times this argument should appear in the command line.

Remarks

The <unnamed> 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 and an argument named server in the WSHNamed arguments collection.

Note

The name attribute of the unnamed element is just for display purposes.

When setting the required attribute, a Boolean value is converted to an integer; "true" becomes 1 and "false" becomes 0.

Example

Here are a couple of examples of how the various attributes affect the usage with unnamed elements. First, a simple case:

<job>
<runtime>
<unnamed
  name="filename"
  helpstring="The file to process"
  many="false"
  required="true"
/>
</runtime>
<script language="JScript">
  WScript.Arguments.ShowUsage();
</script>
</job>

This produces the following:

Usage: example.wsf filename

Options:
filename : The file to process

In the next example, change the code as follows, changing required to 3:

<runtime>
<unnamed
  name="filename"
  helpstring="The files to process"
  many="false"
  required="3"
/>
</runtime>

Your output changes to:

Usage: example.wsf filename1 filename2 filename3

Options:
filename : The files to process

The many argument displays ellipses to indicate you can enter more files than indicated. In this final code example, change your code as follows:

<runtime>
<unnamed
  name="filename"
  helpstring="The file(s) to process"
  many="true"
  required="1"
/>
</runtime>

The output changes to:

Usage: example.wsf filename1 [filename2...]

Options:
filename: The file to process.

See Also

Reference

ShowUsage Method

<runtime> Element (Windows Script Host)

<named> Element

<description> Element (Windows Script Host)

<example> Element