How to open a link in another browser

I had a somewhat unusual request from one of my customers with a very locked down corporate network.

Their intranet (and other internal web applications) are only available in IE. But for security reasons, you are not allowed to access any external site using IE. Instead all users have a locked down version of Chrome available that has a proxy defined that you can use to access external sites but of course none of the internal applications or the intranet.

So how do you create links on your intranet that are opened in another browser?

To overcome this problem I created an application that registers protocol handlers for extern:// and externs:// that opens these URLs in Chrome to make it possible to open external links on the Intranet when using IE.

On the intranet site links to external resources has to be rewritten so they look like this:

<a href="extern://www.aftonbladet.se/">Aftonbladet</a>

My Launcher Application is available as Open Source on github.

So how does it work? First, you have to modify the registry to register an application that can handle the protocol (like http, https, mailto, ftp, etc).

Then whenever a link starting with your protocol is clicked the browser will launch your application and you can replace “extern” as protocol with “http” and launch Chrome to open the link.

As you can see I use the registry to locate where Chrome is installed since it can end up in a lot of different places depending on how it is installed and the language of the operating system. Chrome can be installed for one user or all users on a machine so we need to look both in the registry for the machine and the current user.

Finally, you will probably run into User Account Control and you are only allowed to change the registry if you are an administrator. Admin privileges are only needed during setup, not to launch Chrome. Since UAC strips away the Administrator group your application will not have admin rights even if you are an Admin. To solve this I check for the privileges and if they are missing restart the application using the “runas” verb. This will ask for elevation if you are an administrator or popup a login dialog if you are an ordinary user.

More about protocol handlers

The technique above can be used for many other things when you want to communicate with desktop applications. I have used it for batch printing a lot of uploaded documents and opening a CRM system showing the right record. Spotify also uses this technique to be able to start playing when you click och a playlist link in your browser.

Mobile Apps can also register protocol handlers. So this technology can be used to forward data and launch and App from a web page in your mobile browser too.