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



我有一个VBScript,触发HP ALM测试与UFT一起运行—该vbs只有在cmdcscript中触发才能工作。

我想知道我如何避免首先去cmd触发它,但只是创建另一个vbs,将触发文件在cscript cmd中运行。或者你有更好的解决办法。

下面的代码不能工作

Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd.exe"   "" c:WindowsSysWOW64cscript.exe C:TempUnattended.vbs""
Set oShell = Nothing

下面是几个运行VBS的示例。如果您的系统默认运行cscript,最后一个选项应该可以工作。

Set objShell = CreateObject("WScript.Shell")
'run with wscript
objShell.Run("""C:WindowsSystem32wscript.exe"" ""C:TestMyScript.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:WindowsSystem32cscript.exe"" ""C:TestMy 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:TestMy Script.vbs""")

最新更新