Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: rundll32 is the right answer!

by rduke15 (Sexton)
on Apr 10, 2005 at 16:47 UTC ( #446422=note: print w/ replies, xml ) Need Help??


in reply to Re:
in thread How do I launch my browser in Win32 to go to a specified URL?

I came across this thread several years after the original post, and would like to confirm that this rundll32 solution works perfectly. It is also much better than the Win32::Shell solution, because it doesn't require a module install.

Before finding the answer here, I had tried extracting the http handler program from the registry and calling it directly. That seemed fine until I tried to switch my default browser to Internet Explorer. The exe lives in "C:\Program Files\Internet Explorer\iexplore.exe" so exec() cannot be used because of the spaces in the path. system() worked, but the script doesn't return until the Explorer window is closed.

I have now

my $url = $baseurl . join("&", map {"$_=$params{$_}"} keys %params); my $cmd = qq{rundll32 url.dll,FileProtocolHandler "$url"}; exec $cmd;
which works reliably.

The next question will be how to achieve the same thing on Mac and Linux to have a multi-platform script, but that will be in another thread.


Comment on Re^2: rundll32 is the right answer!
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://446422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2013-05-25 11:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (519 votes), past polls