0

How to register the custom URL protocol so that when i pass the protocol as suffix that URL will open in that browser. I have created ONE chrome > shell > open > command and than in default chrome.exe full path. But when i add that protocol to url for example chrome:http://google.com that does not open google.com in chrome it opens only the blank chrome page.

Thank you in advance

0

1 Answer 1

0

A protocol handler just calls the registered command with the full url as a parameter.

If in the registry you set "c:\path\to\chrome.exe" %1 as the command and then launched chrome:http://google.com, Chrome.exe would be started with chrome:http://google.com as the parameter and this is not going to work because Chrome does not know what to do with that url. Because you said it just opens a new blank page I suspect you failed to even specify %1 in the registry.

If you want to invent a new protocol for a 3rd-party application you would have to make your own launcher that transforms the url before passing it to Chrome.

Example batch launcher:

@echo off setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION if /I "%1"=="Install" goto install set url= echo I was started with %* for /f "tokens=1,* delims=:" %%a in ("%*") do set url=%%b echo URL to use is %url% if defined url start chrome.exe %url% goto :EOF :install reg add HKCU\Software\Classes\Chrome /v "URL Protocol" /d "" /f reg add HKCU\Software\Classes\Chrome\shell\open\command /ve /f /d """"%~f0""" %%1" echo Registered, now testing... start chrome:http://google.com 

(Save as .bat and execute it once in cmd.exe with Install as the parameter)

Sign up to request clarification or add additional context in comments.

6 Comments

should sorry i am new here, so how should i do this. you mean create custom url to CMD.EXE path and than how should i pass the bat file to execute in app ? i am trying to add this in JSP page.
No, write my code to chromeproto.bat, run cmd.exe, cd to where the .bat is and execute chromeproto.bat Install
I tried this with and without quotes around the %1 and while it does open Chrome it doesn't open the nominated page. Also tried adding the "URL Protocol" string value that Firefox uses.
@WilliamK Use Process Monitor to view new processes started and make sure the command line is as expected. Also, using this .bat file is not ideal, pointing the command at something else is preferable, ideally a real .exe.
I have been testing the use of Protocol Handlers on Windows to launch a custom browser from other browsers and open a designated URL by creating a registry key for MyBrowserURL. That registry key can be added by MyBrowser install. MyBrowser launches ok but its not opening the URL. I also tested launching Firefox and Chrome and they fail also.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.