Custom Protocol Handler

Tags: Windows

Have you ever wanted to define a link on a webpage to open a specific, different browser? Perhaps you have a corporate application that only supports Firefox (or Chrome) but your main application set works only in IE.

Well, in Windows at least, you can define your very own custom protocols - Microsoft describes how to do that in MSDN. In fact as you can see at the bottom, they even have some sample code.

The problem with that particular implementation is that it relies on the application being called knowing how to process the "custom" protocol. So Firefox would have to know that a firefox:// URL should really be interpreted as

So instead I've written a more generic handler application that lets you define your own mapping of custom protocol to application+real protocol. Any application that allows Windows to "do its thing" with a URL should be able to find and execute the custom handler, which identifies the correct program to run and loads it up with the corrected URL.

An example will help.

Configure your URL types in the app.config file.  There are three parts to a setting - the custom protocol, the application path and the "true" protocol.

These settings are stored in the form:
      CustomProtocol=Application Path,Protocol

For example, to handle URIs with a new protocol called "cisco" you might define a setting as shown:
      cisco=C:\Program Files\PuTTY\putty.exe,ssh

Calling this application with the command line
would then cause this application to run:
      C:\Program Files\PuTTY\putty.exe ssh://

Code (and eventually, downloadable application) located at GitHub for ease of access.

No Comments