How Does Your Browser Know that It’s Not The Default?

On Windows system, how does your browser tell that it’s currently not the default? Prior to Windows Vista, this information is stored in the registry under HKEY_CLASSES_ROOT hive, the usual place where all shell associations are kept. The default browser is maintained under HKEY_CLASSES_ROOT on per-protocol basis (as well as per file type basis, but I’m only interested in the protocols since we use browsers most of the time to access online resources, not offline). The convention for registry locations, where protocol-application associations are stored; is “HKEY_CLASSES_ROOT\[protocol]\shell\open\command “. Substitute [protocol] here with http, https, ftp, gopher or other protocols commonly supported by your favorite browser.

For example: if I want to know what is the default program for opening http protocol, then I’ll look at the registry value of “HKEY_CLASSES_ROOT\http\shell\open\command”. If I go to Start menu, click Run, type “” and then hit Enter, the URL will be opened with the application of which command line is registered in this registry value. As simple as that.

The next question will be, whether the default browser is maintained on per-user basis or it’s a system wide setting. If it’s maintained on per-user basis, then if user A set his default browser, then it will not change the default browser for user B or C. This would be somewhat the desired behavior, don’t you think? Imagine a family whose members are computer versed or so they thought, sharing one PC, and they constantly have fight over IE vs Firefox vs Opera. You don’t want the default browser to be system wide setting in that family’s PC.

But unfortunately, the answer is not straightforward. The default browser setting can be both per-user and system-wide. To understand this, you need to understand HKEY_CLASSES_ROOT hive. There’s no better place to start than MSDN documentation. In summary, there are 3 important concepts about HKEY_CLASSES_ROOT that we have to keep in mind:

  1. The HKEY_CLASSES_ROOT key provides a merged view of “HKEY_LOCAL_MACHINE\Software\Classes” (contains default settings that can apply to all users on the local computer) and “HKEY_CURRENT_USER\Software\Classes” (contains settings that apply only to the current interactive user).
  2. The user-specific settings have priority over the default settings.
  3. If you write values to a key under HKEY_CLASSES_ROOT, the values will go under:
    • HKEY_CURRENT_USER\Software\Classes; if the key exists under HKEY_CURRENT_USER\Software\Classes.
    • Otherwise, HKEY_LOCAL_MACHINE\Software\Classes.

Windows basically requires browsers to do the right thing to make the settings per-user basis instead of system-wide. In ideal scenario, before writing the default browser settings to HKEY_CLASSES_ROOT, browsers need to check if the key already exists under HKEY_CURRENT_USER or not. If the key exists there, then writing to HKEY_CLASSES_ROOT will be equal to committing to HKEY_CURRENT_USER; meaning that the settings will only affect the current interactive user and not other users. If the key doesn’t exist, then no question the key must be written under HKEY_CURRENT_USER instead of HKEY_CLASSES_ROOT. However, most (if not all) browsers basically write to HKEY_CLASSES_ROOT blindly, and since the protocol-association registrations do not exist under HKEY_CURRENT_USER by default, that means browsers write the settings to HKEY_LOCAL_MACHINE all the time. That is not only annoying and disruptive, the attempt to overwrite default browser may ultimately fail as well.

Consider the scenario of standard or limited user accounts. They don’t have write access to HKEY_LOCAL_MACHINE\Software\Classes. So if standard user says “Yes” when asked by browser X to set X as default browser, and X writes the settings to HKEY_CLASSES_ROOT which ultimately passed-through to HKEY_LOCAL_MACHINE; the registry write operation will fail. As a result, browser X will ask the same question next time it’s launched by this standard user. More frustration for the user!

Realizing these bad-eggs and with good intentions to prevent users from stepping on each other’s toes, Windows Vista introduces new way of registering default browser. It’s part of the new feature called Default Programs. It’s different to Windows XP’s SPAD (Set Program Access and Defaults) in that Default Programs is primarily controlled at the per-user level instead of per-machine level (out of the box! And does not rely on 3rd party programs to do the right thing). As part of this Default Programs, the default browser settings are now stored under “HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\[ftp|http|https]”. Windows Vista’s shell will launch a URL with an application associated with the URL’s protocol based on the value of these registry keys. Browsers that were not aware of this change broke on Vista, they were simply unable to set itself as default browser (they saw themselves as default browser although shell didn’t think so because the twos were looking at 2 different registry keys).

Windows shell team introduced a new shell object called ApplicationAssociationRegistration to allow application registering itself as default for a particular type or protocol, as well as querying the current default. This shell object is only available on Vista, and therefore incorporating that in the code that is also targeted for previous Windows versions needs to be done with care. Tomorrow I’ll talk about how to use ApplicationAssociationRegistration shell object in a code base that is not exclusively targeted for Vista.


Posted on March 23, 2007, in Code Junky. Bookmark the permalink. 43 Comments.

  1. Very informative and useful post. I was wondering why HKCR\HTTP\blah doesn’t change when I switch default browsers.
    Your post explains it all. I’m using Vista.
    Problem solved! Thanks!

  2. Well written article. Thanks

  3. Really its an excellent article. It saved good amout of my work time…

    Thanks a lot.

  4. Hmm, I successfully changed my default browser to a batch file I wrote that opens Firefox with a specific profile in XP using the above instructions. Works great. But on Vista I can’t seem to do it. In

    “HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\[ftp|http|https]“

    I find not application paths but a key called ‘Progid” with the value “FirefoxURL” and I don’t know what to do!

  5. Karandeep Malik

    In case of Vista, the Progid key in HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\http stores the required info FirefoxUrl -> Firefox and IE for Internet Explorer

  6. It is a great article, but it lacks a point of clarification, as Aaron pointed out.

    Once you open the “HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice“, you will find a Progid, representing the User Choice.

    With the Progid at hand, you can check the “HKEY_CLASSES_ROOT\[Progid]”, which you then can treat as a normal “http/ftp/https” key from XP.

    Hope this helped 🙂

  7. Excellent article, thanks for taking the time.


  8. Thanks a lot

    very helpfull and comprehensive article.


  9. Excellent article, thanks.

  10. Thank you very much for this article. It was very helpful for my free software tool (Bestellbuch 3 -> Now i can open links (helpsystem inside the program) with pointers to a section.

    Up to windows xp it comes by itself (link#pointer), on vista or higher, it dont works anymore with shellexecute.

    With best regards

  11. Philippe Marechal

    Thank you for your very helpful article. I first thought I had to go to “the old new thing” blog to find this information ;o)

  12. Informative article. Thanks for that.

  13. Thanks buddy,

    “HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\[ftp|http|https]“
    Really its a very straight forward key’s to change the default web browser.

    What is the similar registry key in Windows XP to change the default web browser?

  14. Thank you. You’ve cleared up a deep dark mystery.

  15. […] How Does Your Browser Know that It’s Not The Default? « The New Old Thing […]

  16. Thanks, this was very helpful

  17. This is a great article! Thanks for taking the time to write it up and post it!

  18. Very well written and instructive. What if I put a shortcut to portable chrome and rename it chrome.exe on login and then replace it with the local chrome path whenI log off? I know nothing about windows, but I assume that would be a relatively easy script/batch file to write?

  19. Thanks for this article. You answered my question for Windows 7.

  20. You could definitely see your expertise within the work you write.

    The sector hopes for even more passionate writers like you who are not afraid to mention how they
    believe. Always follow your heart.

  21. What a data of un-ambiguity and preserveness of precious experience regarding unexpected emotions.

  22. Hi, I do think this is a great site. I stumbledupon it 😉 I will revisit once again since I book-marked it.
    Money and freedom is the greatest way to change, may you be rich and continue to help others.

  23. I was recommended this blog by my cousin. I am not sure whether this post
    is written by him as no one else know such detailed about my problem.
    You are amazing! Thanks!

  24. My website siemens simatic s7 200

    First off I would like to say superb blog! I had a
    quick question which I’d like to ask if you do not mind. I was curious to know how you center yourself and clear your head before writing. I have had a tough time clearing my thoughts in getting my ideas out there. I do take pleasure in writing however it just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any ideas or hints? Thanks!
    My website komunikacja profibus

  25. Nice blog! Is your theme custom made or did you download it from somewhere?

    A design like yours with a few simple tweeks would really make my blog shine.
    Please let me know where you got your design. Appreciate it-
    rgrds hl3c53yx

  26. I feel this is among the most significant information for me.
    And i’m happy reading your article. But wanna statement on few normal issues, The web site style is ideal, the articles is actually excellent : D. Just right process, cheers

  27. When someone writes an post he/she retains the image of a user in his/her brain
    that how a user can understand it. Therefore that’s why this piece of writing is amazing. Thanks!

  28. Great beat ! I would like to apprentice while you amend your site,
    how can i subscribe for a blog site? The account helped me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast
    provided bright clear concept

  29. You are so interesting! I don’t suppose I’ve read
    through anything like this before. So good to discover another
    person with some original thoughts on this subject matter.
    Seriously.. many thanks for starting this up. This site is one thing that is needed on the web, someone
    with a little originality!

  30. My family members every time say that I am wasting my time here at web, except
    I know I am getting knowledge all the time by reading thes pleasant articles or reviews.

  31. We’re a group of volunteers and opening a new
    scheme in our community. Your website offered us with valuable
    info to work on. You have done a formidable job and our whole community will be grateful to you.

  32. nice article, just the info needed.

  33. Neat blog! Is your theme custom made or did you download it
    from somewhere? A design like yours with a few simple adjustements
    would really make my blog shine. Please let me know where you got your design. Thanks a lot

  34. Well it’s over 8 years since you wrote this blog … but just thought I’d let you know that it is still helping folk … like me !! Thanks.

  1. Pingback: Teknovis » Firefox Default Browser

  2. Pingback: XP login script dat IE default browers maakt - 9lives

  3. Pingback: Default browser « Hoa Chau’s weblog

  4. Pingback: What is the registry setting required to set Internet Explorer as the default browser? Drija

  5. Pingback: What is the registry setting required to set Internet Explorer as the default browser? - Admins Goodies

  6. Pingback: What is the registry setting required to set Internet Explorer as the default browser? - Just just easy answers

  7. Pingback: How to use a different default browser for different websites

  8. Pingback: What is the registry setting required to set Internet Explorer as the default browser? | XL-UAT

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: