Windows 脚本宿主  

<runtime> 元素

将某个脚本的一系列运行时参数组合起来。

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

说明

ShowUsage 方法使用由 <runtime> 元素括起来的信息,以便显示脚本的运行时参数。

由于 <runtime> 元素括在一对 job 标记中,因此所定义的运行时参数只适用于该作业。

注意   使用 5.6 版,<runtime> 元素中所括的数据只用于自我说明,以及为 ShowUsage 所显示的数据设置格式。<runtime> 元素不对它所包含的参数强制实施值集合(即命令行中丢失“必需的”参数不会导致错误)。如果 <runtime> 元素包括在 .wsf 文件中,则用 "/?" 参数运行脚本将会显示用法并退出。

示例

下面的脚本将演示 <runtime> 元素的用法:

<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();
  }
// ... 此处是一些脚本
</script>
</job>

请参阅

ShowUsage 方法 | <named> 元素 | <unnamed> 元素 | <description> 元素 | <example> 元素