How to open each internet browser if one is not available in the sytem?

rcgomez11

Member
Windows 7 Professional x64
Progress 10.1C

Good day ProgressTalkers,
I got a module that triggers internet browser to opens-up and directed to go a certain website. The problem is, I wanted to add some features of if that internet browser is not available in the system, e.g. I want to open "Google Chrome" then if that browser is not yet installed in my system the next internet browser the module will try is "Mozilla Firefox" then again if that is not available it will look for "Internet Explorer".

Code:
    OS-COMMAND SILENT VALUE("START chrome.exe http://www.someWebsite.com/") NO-ERROR.
    IF ERROR-STATUS:ERROR THEN DO:
        OS-COMMAND SILENT VALUE("START firefox.exe http://www.someWebsite.com/") NO-ERROR.
    END.

I'm trying the above code but "Error-Status:Error" gives me a "No" logical value always even I tried to make "chrome.exe" into "xChrome.exe" which is incorrect and not available to my system.
I hope I made myself clear about the problem i'm having now. I know it's just a piece of cake to you guys and hope to hear from you. Thanks in advance and more power to ProgressTalk.

Sincerely,
Romel Gomez
 

RealHeavyDude

Well-Known Member
The ERROR-STATUS will only catch errors generated by ABL statements. In this case the ABL opens a shell and the error happens in the shell and the ABL is completely oblivious to it. Even the documentation state that the OS-COMMAND will always set the OS-ERROR to 0 so you can't use that. Usually I call a cmd in which I prints the exit code of the OS command into a file which I read from the ABL to see if and what error happened. That's the only way that I found that somehow holds water.

I guess the best way to find out which browsers are available on the system is to query the registry. You can do that from within the ABL with code like that ( coded in Firefox IDE - not syntax checked ):
Code:
 /* Open the Windows registry */
LOAD 'SOFTWARE':U BASE-KEY 'HKEY_LOCAL_MACHINE':U.
USE 'SOFTWARE':U.

/* Fetch a value */
GET-KEY-VALUE SECTION 'xyz\xyz':U VALUE cxyz.

 /* Close the Windows registry */
 UNLOAD 'SOFTWARE':U.

Heavy Regards, RealHeavyDude.
 

Marian EDU

Member
I'm trying the above code but "Error-Status:Error" gives me a "No" logical value always even I tried to make "chrome.exe" into "xChrome.exe" which is incorrect and not available to my system.

true, say so in the help as well... os-command unlike other os-* commands never set the os-error either so you don't really know if it failed or not :(

you might try this... or use input-output through to read the `program not found` line :)

Code:
os-command no-wait value('start http://www.google.com'). /* win */
os-command no-wait value('xdg-open http://www.google.com'). /* linux */
 
Top