Home > OS >  How to register the custom URL protocol for Chrome
How to register the custom URL protocol for Chrome

Time:10-28

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

CodePudding user response:

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)

  • Related