Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 provided by Microsoft 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 :

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.

like image 716
Shubham Shrivastava Avatar asked May 23 '13 07:05

Shubham Shrivastava


People also ask

How do I change my Default browser in CMD?

The Short Answer: Use the SetDefaultBrowser tool made by Christoph Kolbicz. Run it once with no command-line options to see your browsers. Then run something like SetDefaultBrowser.exe HKLM FIREFOX. EXE to switch to Firefox, or SetDefaultBrowser.exe HKLM "Google Chrome" to switch to Chrome.

How do I set chromium as Default?

To make Chromium your default browser, do the following: Click on the Wrench icon and select Options (Windows OS) or Preferences (Mac and Linux OSs). In the Basics tab, click on Make Chromium my default browser in the Default browser section.


1 Answers

For all those waiting for answer to this question.

Here you go, looks like that one of the way to do it is through DISM.exe provided by Win 8. Your user should be admin of the machine though.

Using C# code you should be able to run this DISM.exe with specific parameters.

Following blog has the details.

http://blogs.technet.com/b/mrmlcgn/archive/2013/02/26/windows-8-associate-a-file-type-or-protocol-with-a-specific-app-using-a-gpo-e-g-default-mail-client-for-mailto-protocol.aspx

Thanks.

like image 152
Shubham Shrivastava Avatar answered Sep 29 '22 13:09

Shubham Shrivastava