2

I'm currently writing a powershell function that (in the end, hopefully) will function identically to Google's advanced search in order to help teach myself scripting. Using this blog article I was able to put most of the functionality together, but noticed that when trying to 'start' a url with quotes in it, it doesn't function the way I expect it to.

For example, when I put the following in powershell:

start "http://google.com/search?&as_q=hi&as_oq=`"there+how+are`"+you"

Chrome will launch with the url without the "'s around 'there+how+are'.

If I put the URL in manually, without the gravemarkers, it works as expected.

I'm on Windows 10. My default browser is google chrome.

Thanks!

  • Not certain (hence comment, not answer), but I think you can do start --% "http...... The --% tells PS to stop parsing the remainder of the command. – Twisty Impersonator Sep 18 '17 at 2:37
  • Doesn't seem to work. I think it's causing Powershell to stop recognizing that the enclosed value is a url and needs to be launched in a web browser. I also tried using start chrome.exe --% "url" and that didn't seem to work either; however, I think I may have found a potential workaround that answers my question, which I will post below. – mystbinder Sep 18 '17 at 21:42
3

One can use url encoding for special characters - i.e. %20 is equivalent to having a single space in the url. It turns out %22 is equivalent to double quotes. See this w3schools link for a large list of url encodings.

With that information, it follows that this command does the trick:

start "http://google.com/search?&as_q=hi&as_oq=%22there+how+are%22+you"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.