Jump to content

Can't open Web page


Luke
 Share

Recommended Posts

This URL points to a Google News search results page:

http://news.google.com/news?hl=en&q=winnipeg

I want a script to open that page in the default browser. However, in this script the URL is cut off before the & character:

$url = "http://news.google.com/news?hl=en&q=winnipeg"
Run(@ComSpec & " /c start " & $url, "", @SW_HIDE)

With some URLs (e.g., http://www.m-w.com/cgi-bin/dictionary?book...ry&va=winnipeg), a workaround is to substitute %26 for &:

$url = "http://news.google.com/news?hl=en%26q=winnipeg"
Run(@ComSpec & " /c start " & $url, "", @SW_HIDE)

But that doesn't work here. In both cases the page that opens is the Google News home page.

Link to comment
Share on other sites

The shell is interpreting the & . The & is utilized by the shell like the unix ; , to allow multiple commands on one line.

Handle the URL like you would spaces in a command line.

$url = '"' & "http://whatever.xxxx" & '"'

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

The command interpreter doesn't treat the & as a part of the program you want to run.

I have a workaround.

Use my _ShellExecute UDF available here.

And run your script like this:

#include "_ShellExecute.au3"

_ShellExecute('http://news.google.com/news?hl=en&q=winnipeg', @SystemDir)

I just tested the script and I can confirm it works.

Link to comment
Share on other sites

Thank you both.

flyingboz, this doesn't work for me.

$url = '"' & "http://news.google.com/news?hl=en&q=winnipeg" & '"'
Run(@ComSpec & " /c start " & $url, "", @SW_HIDE)

SlimShady, yes, that works. It doubles the size of my script, but it works.

Link to comment
Share on other sites

flyingboz, this doesn't work for me.

The following tests fine on my box, I think that you may have had a space somewhere wrong. A good test is to copy your command lines onto the

clipboard or user consolewrite() to see EXACTLY what you're getting,

then paste that into a dos box or the start|run menu.

Slim's UDF is great, but mebbe overkill for small scripts.

$url = "http://news.google.com/news?hl=en&q=winnipeg"
$IE= RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\IEXPLORE.EXE\shell\open\command","")
Run(@ComSpec & " /c start " & $IE & ' "' & $url & '"',@WorkingDir, @SW_HIDE)

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...