WScript不适用于HPALM工作流程。但是在命令行中执行时效果很好

时间:2019-06-21 15:27:09

标签: vbscript hp-alm

我正在设置一个新的HP ALM工作流程脚本,以调用firefox并在同一脚本中打开两个选项卡。

给定的脚本在命令行中就像一个超级按钮。但是,同一脚本在HP-ALM工作流流程中无法正常运行。我确定虽然正在调用脚本,但是Firefox浏览器没有打开。放置了调试脚本的警报,并显示了来自脚本的警报。


Dim wshshell
Set wshshell = WScript.CreateObject("Wscript.Shell")

wshshell.run """firefox.exe"" www.google.com",1,False
wshshell.run """firefox.exe"" www.yahoo.com",2,False

Set wshshell = Nothing
wscript.quit

在HP ALM客户端中的“按钮”上单击,应使用两个选项卡打开firefox。一个与谷歌和其他与雅虎主页。但是,没有页面正在打开。

2 个答案:

答案 0 :(得分:0)

您应该使用此标记为Firefox辩护:&

尝试运行:

Dim wshshell
Set wshshell = WScript.CreateObject("Wscript.Shell")
wshshell.run """C:\Program Files\Mozilla Firefox\firefox.exe """&"www.google.com",1,True
wshshell.run """C:\Program Files\Mozilla Firefox\firefox.exe """&"www.yahoo.com",1,True
Set wshshell = Nothing
wscript.quit

答案 1 :(得分:0)

最后,以下解决方案有所帮助;

ActionCanExecute()

Function ActionCanExecute()

    On Error Resume Next
    ActionCanExecute = DefaultRes
    browserName = "Mozilla Firefox"
    browserExeName = "Firefox.EXE"
    cmdLineArgPlatform = " -new-window "
    cmdLineArgIdc = " -new-tab "
    sURLPlatform = "www.google.com"
    sURLIdc = "www.yahoo.com"

    Set WSHShell = CreateObject("WScript.Shell")
    exePath = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\" & _
                     "CurrentVersion\App Paths\" & browserExeName & "\")

    'Open the URL
    sShellCmdPlatform = """" & exePath & """" & "" & cmdLineArgIdc & """" & sURLPlatform & """"
    MsgBox sShellCmdPlatform

    sShellCmdIdc = """" & exePath & """" & "" & cmdLineArgIdc & """" & sURLIdc & """"
    MsgBox sShellCmdIdc

    'MsgBox sFFExe      

    WSHShell.Run sShellCmdPlatform, vbHide
    WSHShell.Run sShellCmdIdc
    On Error Resume Next

    Set WSHShell = Nothing

    ActionCanExecute = DefaultRes

    On Error GoTo 0
End Function