Search code examples
vbscripthp-alm

WScript doesn't work with HPALM workflow. But works fine when executed in command Line


I'm setting up a new HP ALM workflow script to invoke firefox and open two tabs in the same.

The script given works like a charm in command line. However, the same script doesn't work well flow HP-ALM Workflow. I'm certain the script is being invoked though, but the firefox browser is not opening. Placed alerts to debug the script and the alerts from the script are displayed.


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

On a Button click in HP ALM client, firefox should be opened with two tabs. One with google & other with yahoo homepage. However, No page is opening.


Solution

  • Finally, the following solution helped;

    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