Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explorer.exe cannot open URLs with arguments in them #3832

Closed
cheshrkat opened this issue Feb 9, 2019 · 3 comments
Closed

explorer.exe cannot open URLs with arguments in them #3832

cheshrkat opened this issue Feb 9, 2019 · 3 comments

Comments

@cheshrkat
Copy link

Microsoft Windows [Version 10.0.17763.253]
using WSL Ubuntu 16.04.5 LTS

Background: I have a release script which does a bunch of automated things, then guides the user through a couple of manual actions where they have to go to a URL. In other shells the script opens the URL for them to make things easier, but I discovered explorer.exe via WSL cannot open URLs with arguments. It can open URLs without arguments, so this seems like a bug. Albeit not the end of the world, still a bug :)

STEPS TO REPRODUCE...

These do work as expected (that is, the URL opens in the system default browser):

$ explorer.exe http://example.com
$ /mnt/c/Windows/explorer.exe http://example.com

These do not work as expected:

$ explorer.exe https://example.com?foo=bar
$ explorer.exe "https://example.com\?foo=bar"
$ explorer.exe 'https://example.com?foo=bar'
$ explorer.exe 'http://example.com?foo=bar'
$ explorer.exe "https://example.com\?foo\=bar"
$ explorer.exe 'https://example.com\?foo\=bar'
$ explorer.exe http%3A%2F%2Fexample.com%3Ffoo%3Dbar
$ explorer.exe 'http%3A%2F%2Fexample.com%3Ffoo%3Dbar'
$ /mnt/c/Windows/explorer.exe 'http://example.com?foo=bar'

Expected result:
URL opens in browser

Actual result:
Generic file explorer window opens

I did find this workaround:

$ cmd.exe /c start http://example.com?foo=bar

...although I've not yet tested it in my release script (it's something I can't test at home on a weekend :)).

Raising a ticket anyway because it seems like a bug that some URLs will open with explorer.exe and others won't. If it's not considered a bug, this issue should at least tip others off to the workaround.

@therealkenc
Copy link
Collaborator

therealkenc commented Feb 9, 2019

This is continuation #2835 formerly #1625 (message), others. Those talk about spaces a lot, but the problem is the escaping. You need to punch a quote through to the Windows side, otherwise that ? is problematic. The quotes in all the variations you tried are being eaten by /bin/bash. [Trying to http escape the ? was well meaning but won't work in cmd.exe either, for reasons unrelated to WSL.]

You might expect the following to work:

$ echo \"http://example.com\?foo=bar\"
"http://example.com?foo=bar"        <-- same string as you'd want use from a cmd prompt
$ explorer.exe \"http://example.com\?foo=bar\"

But it doesn't. It isn't clear to me whether that is by design or otherwise. Standard operating procedure seems to be to bounce it off cmd.exe or powershell.exe explicitly.

@cheshrkat
Copy link
Author

Thanks for the info. Seems like the other ticket covers it; I'll run with the cmd.exe workaround in the meantime.

@pascal-t
Copy link

pascal-t commented Jul 4, 2022

The cmd.exe workaround did not work for me. It opened the browser but the arguments were gone.
Instead this worked: rundll32.exe url.dll,FileProtocolHandler "https://url.com/path/index.php?arg1=foo&arg2=$bash_var"
From https://stackoverflow.com/a/49115945

Djuuu added a commit to Djuuu/git-mr that referenced this issue Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants