I have an erlang program which runs a server on a local machine and I would like it to start a local web browser and point to itself on startup. How can I do this in a portable way across Windows XP. Vista, and Windows 7?
views:
73answers:
3
A:
You can use the port api in erlang to start a normal command.
For open a browser you have multiple options:
- Look to the IExplorer.exe or how its called and start it with the URL as a parameter
- Use the rundll32.exe command to open a browser through the windows api. I guess this will use the configured browser, so this is recommended.
ZeissS
2010-04-23 00:02:29
+1
A:
Hi, try this:
URL = "http://www.google.com", os:cmd("\"C:\Program Files\Internet Explorer\iexplore.exe\"" ++ URL).
You might have to modify the path if IE isn't located in that folder.
Fabian Alenius
2010-04-23 03:08:38
+2
A:
I would suggest to use the following code on windows systems:
URL = "http://www.google.com/", os:cmd("start " ++ URL).
This has two advantages:
1) No need for the right path of the
browser.
2) Works even if someone doesn't use
IE.
Too bad I don't know of something similar on Linux or MacOS.
bsmr
2010-04-23 04:45:54
Brilliant! That worked first time!
Zubair
2010-04-23 08:19:22
bsmr: have a look at the Python source code for the browser module to understand how to achieve the same on Linux and other os for that matter.
jldupont
2010-04-23 12:34:43
@jldupont: thank You for the hint!
bsmr
2010-04-23 14:21:07
For macos replace "start" with "open" and you get the same effect.
Jeremy Wall
2010-04-23 14:49:13