Fork me on GitHub

I recently saw a tweet about having different default browsers on Windows for different urls. This seemed like an interesting idea - I use a few systems that work better in one browser than another. I retweeted and saw a few responses from others that seemed interested in the idea.

It seemed like a pretty easy thing to do - register as a browser and when a url comes in, just bounce it over to the correct “real” browser based on some config. So I thought I’d knock something together…

It didn’t take long, nor much code. There are about 30 lines of code to create (or delete) registry values to register with Windows as a browser, about 60 lines of code to parse a poor version of an INI file, and around 50 lines of plumbing to pull them together and look up the URLs.

Code is up on GitHub (DanTup/BrowserSelector), and a binary release if you just want to run it.

Config looks like this:

; Default browser is first in list
[browsers]
chrome = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
ie = iexplore.exe
	
; Url preferences.
; Only * is treated as a special character (wildcard).
; Matches are domain-only. Protocols and paths are ignored.
; Use "*.blah.com" for subdomains, not "*blah.com" as that would also match "abcblah.com".
[urls]
microsoft.com = ie
*.microsoft.com = ie

It’s a first version, so I’m sure it has bugs and can be improved. I can’t make any promises to evolve it further (it’s hard to find coding time since kids came along!) but since it’s pretty trivial maybe it won’t need much work to improve and fix bugs.