Open Internet Explorer from Chrome using a protocol handler (ie:url)
Asked Answered
P

7

15

I've followed these steps and it doesn't work correctly for me. Custom protocol handler in chrome

Basically, I don't have a custom app. I just want to create an handler to open IE with a specific URL.

Here are my reg:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\ie]
"URL Protocol"="\"\""
@="\"URL:IE Protocol\""

[HKEY_CURRENT_USER\Software\Classes\ie\DefaultIcon]
@="\"explorer.exe,1\""

[HKEY_CURRENT_USER\Software\Classes\ie\shell]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
@="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" \"%1\""

It's working but... when I'm opening ie:www.google.com from Chrome, it ask to open IE but it keeps the "ie:" in the opened URL... which generate a endless loop.

How can I fix that?

Thanks

Screenshot

Promontory answered 10/11, 2016 at 15:35 Comment(2)
You need to remove the ie: schema from the url. Use @="cmd /v:on /q /c \"set url=%1 & start C:\\PROGRA~1\\INTERN~1\\iexplore.exe !url:~3!\" " on line 14Sap
If I understand correctly, you control both sides (1. the side that creates the url and 2. the side that reads the url and forwards to IE), so you can come up with a special escaping scheme of your own.Jeanniejeannine
P
1

After few tests, I move to another strategy. I'm targetin an intermediate batch script instead. And the batch split the protocol and the url, and open IE.

Here is the batch:

echo %1%
set var=%1
set var=%var:~4,-1%
Start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" %var%
Promontory answered 11/11, 2016 at 8:43 Comment(1)
So how do you run this script from chrome?Dekker
E
9

Create a Protocol Handler

save this script as internet-explorer-protocol-handler.reg:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\ie]
"URL Protocol"="\"\""
@="\"URL:IE Protocol\""

[HKEY_CURRENT_USER\Software\Classes\ie\DefaultIcon]
@="\"explorer.exe,1\""

[HKEY_CURRENT_USER\Software\Classes\ie\shell]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
@="cmd /k set myvar=%1 & call set myvar=%%myvar:ie:=%% & call \"C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe\" %%myvar%% & exit /B"

Then run the script to install the keys in your registry. It will look like this:

registry

Now links that use the ie: protocol will open in Internet Explorer.

<a href="ie:https://www.google.com/">Google</a>

Demo Page

Equipment answered 19/1, 2017 at 18:27 Comment(5)
Somehow it doesn't work if the url contains special characters like = or &.Fibre
Open Chrome from Internet Explorer ?Patrizius
url with params like example.com?a=1&b=2 will not work properly. It will be stripped to example.com?a=1 and b is ignored.Dekker
@Jeremy Danyow It works perfectly!! The problem is that before opening, Chrome shows a dialog: "Open Windows command processor". Can confirmation be avoided?Kryska
@gabi13, Where you able to find the solution, i also trying to find to disable to opening of cmd processor. Also, the secondary parameters are not capturing while loading the new browser.Coenurus
S
2

Here is a solution that should solve the problem with extended url's that contain parameters and special characters (&, % etc.)

Like this: https://www.google.com/search?q=open-internet-explorer-from-chrome-using-a-protocol-handler&oq=open-internet-explorer-from-chrome-using-a-protocol-handler&aqs=chrome..69i57j69i60l3.1754j0j4&sourceid=chrome&ie=UTF-8

Replace the command in reg file with this:

powershell -windowstyle hidden -command "& {$Url = '%1' ;  $Url = $Url -replace 'ie:',''; $IE=new-object -com internetexplorer.application ; $IE.navigate2($Url) ; $IE.visible=$true }"
Switcheroo answered 9/5, 2019 at 14:16 Comment(0)
P
1

After few tests, I move to another strategy. I'm targetin an intermediate batch script instead. And the batch split the protocol and the url, and open IE.

Here is the batch:

echo %1%
set var=%1
set var=%var:~4,-1%
Start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" %var%
Promontory answered 11/11, 2016 at 8:43 Comment(1)
So how do you run this script from chrome?Dekker
D
1

Working registry:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\ie]
"URL Protocol"=""
@="URL:IE Protocol"

[HKEY_CURRENT_USER\Software\Classes\ie\shell]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
@="cmd /c set url=\"%1\" & call set url=%%url:ie:=%% & call start iexplore -nosessionmerging -noframemerging %%url%%"

Some important notes:

  1. You have to wrap %1 in double quotes. Otherwise url with multiple params like example.com?a=1&b=2 will be stripped to example.com?a=1, params after & will be ignored.
  2. You have to remove the double quotes when calling iexplore. If you don't remove the double quotes and open multiple IE window from chrome, only the first IE window will get the correct URL. But removing quotes with command set url=%%url:\"=%% or set url=%%url:~1,-1%% doesn't work.
  3. If you just can't make it to remove those quotes, add switches -nosessionmerging and -noframemerging to iexplore. These are command-line options to control "merging" behavior for IE.
Dekker answered 17/5, 2019 at 1:27 Comment(1)
It works fine. But except a small cosmetic related stuff. When I click a button, I'm getting a prompt like "Open Windows Command Processor". Is there a way to hide this prompt so that user no need to click "Open Windows Command Processor" all the time?Forefront
U
0

The implementation of the registry will be more generic if you last line of the registry as

@="cmd /C set myvar=%1 & call set myvar=%%myvar:ie:=%% & call start /separate iexplore %%myvar%% & exit"

You wont need to create a custom script.

In case, the target URL can have more than 1 query params, you might face an issue that only the first param gets passed to IE (check the address bar on IE to validate). In such a case, you can go for the following workaround ... simply create a new html file passing the target URL after encoding it and open this HTML on IE.

window.location = "ie:"+<URL to the above HTML>+"?path="+encodeURIComponent(<target URL>);

In the HTML file, just redirect to the decoded target URL

<html>
	<head>
		<title>
			IE Redirect
		</title>
		<script>
			function getUrlVars() {
				var vars = {};
				var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
				function(m,key,value) {
					vars[key] = value;
				});
				return vars;
			}

			function openURL(){
				window.location.href=decodeURIComponent(getUrlVars()["path"]);
			}
		</script>
	</head>
	<body onload="openURL()">

	</body>
</html>

The above worked perfectly in my application.

Underlay answered 5/11, 2017 at 7:56 Comment(0)
L
0

the following command will work for all query params to be passed:

cmd /C set myvar="%1" & call set myvar=%%myvar:ie:=%% & call start /separate "iexplore.exe" %%myvar%% & exit

Liebman answered 18/10, 2018 at 4:32 Comment(0)
U
0

the following command will work for all query params to be passed:

cmd /C set myvar="%1" & call set myvar=%%myvar:ie:=%% & call start /separate "iexplore.exe" %%myvar%% & exit

We need to use the double quotes when a link had an ampersand in it and would not open in IE11 as anything after the ampersand was trimmed off.

Unbounded answered 18/9, 2019 at 15:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.