How to set default browser in windows 8 using C#?


  • We all have been easily able to do this prior to Windows 8 (in XP/VISTA/WIN7) with few changes in Registry and it was done.

    With Windows 8 it's not that easy (I'm yet to figure it out how). Windows 8 too has few registry settings to be changed mentioned below, but along with this it also stores a unique Hash for every computer. Can any body help me to possibly create this hash for every computer or with some API to set default browser ('SetAppAsDefaultAll' does not work). Following are the registry entries.

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.htm\UserChoice Progid : IE.AssocFile.HTM Hash : XXXXXXXXXXX

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.html\UserChoice Progid : IE.AssocFile.HTM Hash : XXXXXXXXXXX

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.xht\UserChoice Progid : IE.AssocFile.XHT Hash : XXXXXXXXXXX

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.xhtml\UserChoice Progid : IE.AssocFile.XHT Hash : XXXXXXXXXXX

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice Progid : IE.FTP Hash : XXXXXXXXXXX

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice Progid : IE.HTTP Hash : XXXXXXXXXXX

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice Progid : IE.HTTPS Hash : XXXXXXXXXXX

    Many Thanks in advance.

    Thursday, May 23, 2013 7:24 AM


  • This is an alternate way but this is not achievable through code

    If you have your browser solution ready, you can create an installation setup file of it from Menu Option Build->Publish "Your Project Name".

    Then install the same in your PC and after it is installed, you can change your default browser from

    Control Panel->Default programs

    Mark as answer if this solves your problem. ... Best Regards D. Chatterjee MCA, RERF

    Thursday, May 23, 2013 1:49 PM
  • Change registry key for the

    HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\http

    Say you want to change your default browser to IE using c#

    RegistryKey regkey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\shell\\Associations\\UrlAssociations\\http\\UserChoice", true);
    string browser = regkey.GetValue("Progid").ToString();
    if (browser != "IE.HTTP")
          regkey.SetValue("Progid", "IE.HTTP");

    Hope this works

    Mark as answer if this solves your problem. ... Best Regards D. Chatterjee MCA, RERF

    Thursday, May 23, 2013 2:03 PM

All replies