Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Internet Explorer to handle custom protocol handlers correctly?

I would like a website I am developing to open PuTTY on ssh://0.0.0.0 type urls. I got this feature working in Chrome and Firefox, but get the following errors in Internet Explorer:

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access this item.

Followed by:

Unable to open this helper application for ssh://0.0.0.0/.

The protocol specified in this address is not valid. Make sure the address is correct, and try again.

Here are my registry keys:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ssh]
@="URL:SSH Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\ssh\shell]

[HKEY_CLASSES_ROOT\ssh\shell\open]

[HKEY_CLASSES_ROOT\ssh\shell\open\command]
@="cmd /k set in=\"%l\" & call set in=%%in:ssh:=%% & call set in=%%in:/=%% & call \"C:\\Program Files (x86)\\PuTTY\\putty.exe\" %%in%% & exit"

I did a quick experiment, and it looks like the issue is due to cmd and call. As soon as I remove those, I get the expected outcome. However, I still need to do the string manipulation as PuTTY (and an identical situation for vnc urls using RealVNC VNC Viewer) only expects the host without the protocol prefix.

Edit: It seems to be cmd only that is causing the issue. call can be used with the expected behavior.

like image 318
ubomb Avatar asked Apr 08 '15 18:04

ubomb


1 Answers

I guess there is a permissions issue with cmd.exe being called by Internet Explorer. Instead, I had to start entirely over with PowerShell. Here is the working registry keys with absolutely no additional scripts or PuTTY program modifications that are shown in some workarounds I found online:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ssh]
@="URL:SSH Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\ssh\shell]

[HKEY_CLASSES_ROOT\ssh\shell\open]

[HKEY_CLASSES_ROOT\ssh\shell\open\command]
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -Command \"$uri = [System.Uri]'%l';&\"${env:ProgramFiles}\\PuTTY\\putty.exe\" -P $uri.Port $uri.GetComponents([System.UriComponents]::UserInfo -bor [System.UriComponents]::Host, [System.UriFormat]::UriEscaped)\""

I can now open SSH and VNC links from all three major browsers.

like image 173
ubomb Avatar answered Oct 31 '22 23:10

ubomb