VBS通过cscript中的cmd触发另一个vbs

VBS to trigger another vbs via cmd in cscript

我有一个 VBScript 可以触发 HP ALM 中的测试 运行 使用 UFT - 此 vbs 仅通过在 cmdcscript.

中触发它来工作

我想知道如何避免先去 cmd 触发它,而只是创建另一个 vbs 来触发文件 运行 in cmd with cscript。或者您有更好的解决方案。

下面的代码不起作用。

Set oShell = WScript.CreateObject ("WScript.Shell")

oShell.run "cmd.exe"   "" c:\Windows\SysWOW64\cscript.exe C:\Temp\Unattended.vbs""

Set oShell = Nothing

这里有几个示例如何 运行 VBS。如果您的系统 运行s cscript 默认情况下最后一个选项应该有效。

Set objShell = CreateObject("WScript.Shell")

'run with wscript
objShell.Run("""C:\Windows\System32\wscript.exe"" ""C:\Test\MyScript.vbs""")

wscript.sleep 5000 'waits 5 seconds before running the next script. This is used for display purposes, not because you have to

'run with cscript
objShell.Run("""C:\Windows\System32\cscript.exe"" ""C:\Test\My Script.vbs""")

wscript.sleep 5000 'waits 5 seconds before running the next script. This is used for display purposes, not because you have to

'run with the default program for vbs files (usually cscript)
objShell.Run("""C:\Test\My Script.vbs""")