ISSUE Reading URL from table to use shell to open browser

win 10, lo 7,3,7,3 (64) hSQL 2.51

Hi,

Trying to open my webmail from a button on several forms, as such getting the url from a settings table.

The queries msgbox returns the correct string, the browser however fails to start with a file not found error…

Sub wmail
Dim myVar As String
oConn = ThisDatabaseDocument.DataSource.getConnection("","")
SQL=oConn.createStatement()
result=SQL.executeQuery(“select ““webmailurl”” from ““tblSettings”””)
result.next
myVar = result.getstring(1)
msgbox " " & myVar
FullPath = myVar
TheURL = ConvertToURL(FullPath)
If FileExists(TheURL) Then
SHELL TheURL,2
Else
msgbox “The Url seems to be a problem, please check the settings form”
End if
End Sub

If a remove the IF block and just leave SHELL TheUrl,2 or use Start TheURL, same error occurs.

Appreciate any help, thank you.

Can you post some of this correct strings. Have you tested, if this strings are valid commands in cmd.exe or powershell? (I’m not sure what is called currently in Win10/11).

Hi, thank you for your quick answer.
Yes, the link(s) work fine from the command line.
I have an identical macro to open Thunderbird, which works perfectly ok.
the weburl = http://www.gmx.com

I can run pretty much any url from the command line, batch files, but only seem to be able to use physical links via SHELL aka C:\blah\zxc.exe

You can’t just open cmd.exe, paste http://www.gmx.com there, hit enter and get a browser open. You would get this:

You may SystemShellExecute service and its execute method:

  oShell=createUnoService("com.sun.star.system.SystemShellExecute")
  oShell.execute("http://www.gmx.com",,0)

[quote=“mikekaganski, post:4, topic:79127”]

oShell=createUnoService("com.sun.star.system.SystemShellExecute")
  oShell.execute("http://www.gmx.com",,0)

Hi Mike,

Well yes from the commandline I run start plus url, no prob.
Thank you for your reply - working perfectly !

Right; start is mandatory, and is a cmd.exe's built-in, not some separate program that you may run from Basic Shell function.