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

时间:2016-10-13 14:16:51

标签: vbscript hp-uft wsh

我有一个VBScript触发HP ALM中的测试以使用UFT运行 - 此vbs只能通过cmd cscript触发它。

我想知道如何避免首先转到cmd来触发它,而只是创建另一个vbs,它将触发文件在cmdcscript运行。或许你有更好的解决方案。

以下代码不起作用。

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

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

Set oShell = Nothing

1 个答案:

答案 0 :(得分:0)

以下是一些如何运行VBS的示例。如果您的系统默认运行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""")