【问题标题】:Why this XML script show message only once?为什么这个 XML 脚本只显示一次消息?
【发布时间】:2019-09-17 10:23:30
【问题描述】:

此代码来自 Microsoft script56.chm。为什么只显示一次消息?

我正在学习 Windows Script Host 并在 Windows 命令行中运行 xml.wsf

<package>
    <job id="DoneInVBS">
    <?job debug="true"?>
        <script language="VBScript">
            WScript.Echo "This is VBScript"
        </script>
    </job>

    <job id="DoneInJS">
    <?job debug="true"?>
        <script language="JScript">
            WScript.Echo("This is JScript"); 
        </script>
    </job>
</package>

我希望它显示两条消息。

【问题讨论】:

  • 你怎么称呼它的? - cscript myScript.wsf //job:DoneInVBS //job:DoneInJS
  • 谢谢!我懂了。我在 cmd 中运行cscript js.wsf,它只显示This is VBScript

标签: javascript vbscript wsh


【解决方案1】:

作为I mentioned in the comments,您需要在执行期间指定两个作业,否则它将运行文件中的第一个作业,在本例中为DoneInVBS

Job 元素的文档非常清楚(参见 script56.chm)

要运行 Windows 脚本文件 myScript.wsf 中的第二个作业,请在命令提示符处键入以下内容。

cscript myScript.wsf //job:DoneInJS

要在myScript.wsf 中运行这两个作业,请在命令提示符处键入以下内容。

cscript myScript.wsf //job:DoneInVBS //job:DoneInJS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 1970-01-01
    相关资源
    最近更新 更多