共用方式為


<runtime> Element (Windows Script Host)

 

Groups together the set of run-time arguments for a script.

Syntax

<runtime> 
    <named attributes etc. />
    <unnamed attributes etc. />
    <example>Example Text</example>
    </runtime>

Remarks

The ShowUsage method uses the information enclosed by the <runtime> element to display the runtime parameters for a script.

Since the <runtime> element is enclosed within a set of job tags, the defined run-time arguments apply to that job only.

Note

With version 5.6, the data enclosed by the <runtime> element is used only for self-documentation and to format the data displayed by ShowUsage. The <runtime> element does not enforce the values set for the arguments it contains (i.e. a "required" argument that is missing from the command line does not cause an error). If the <runtime> element is included in a .wsf file, then running the script with the "/?" argument will show the usage and quit.

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

<job>
    <runtime>
        <named
            name="server"
            helpstring="The server to run the script on"
            type="string"
            required="true"
        />
    </runtime>
<script language="JScript">
  if (!WScript.Arguments.Named.Exists("server"))
  {
    WScript.Arguments.ShowUsage();
  }
// ... some script here
</script>
</job>

See Also

ShowUsage Method
<named> Element
<unnamed> Element
<description> Element (Windows Script Host)
<example> Element