3

I have made a program to handle http links. How do I set the default browser to my exe? I only need to change the http protocol, not file associations. I have already setup command line argument handling. I do not want to use a .reg file since it asks the user about adding keys.

msbg
  • 4,852
  • 11
  • 44
  • 73

3 Answers3

3

You could run regedit in silent mode ("/S").

Or run cmd script:

reg add HKEY_CLASSES_ROOT\http\shell\open\command /ve /d "path\to\app \"%1\"" /f

(for registered http handler - overwrite an existing empty parameter in a "\shell\open\command" key).

Update Also you can experiment with default browser (HKEY_CURRENT_USER\SOFTWARE\Clients\StartMenuInternet) as per MSDN article. But you'd also handle local files as well.

mikalai
  • 1,746
  • 13
  • 23
  • I have tried this, and it shows up in registry editor, but if I open an internet shortcut or run an http address, Firefox still opens and not my program. – msbg Oct 14 '12 at 19:37
  • Well you should have mentioned that. Did you try " HKEY_CURRENT_USER\Software\Classes\http\shell\open\command" too? This a current user's particular key mapped to HCR. – mikalai Oct 14 '12 at 19:40
  • The http key does not exist in HKEY_CURRENT_USER\Software\Classes on both my computers. I have changed HKEY_CURRENT_USER\SOFTWARE\Clients\StartMenuInternet from firefox.exe to my browser's path, and no changes have occurred. – msbg Oct 17 '12 at 20:45
2

@TomTom Sorry, I don't have enough rep to comment. ;)

Just because Firefox and a couple of other browsers are popular does not mean that it is somehow "special" in that it can ask you if you want to change the setting. There is NO reason why a custom-made application cannot do the same.

@msbg, since you commented there, you likely already found your answer at how do i change default browser using c# or batch file

There's another answer at How to find all the browsers installed on a machine which refers to http://msdn.microsoft.com/en-us/library/dd203067%28VS.85%29.aspx

Community
  • 1
  • 1
zaTricky
  • 1,838
  • 17
  • 22
1

You do not. This is not a program specific Setting, it is a System wide.

What you CAN do is start a specific exe (the browse) and give it the URL as Parameter. But generally, sorry, this is a System wisde Setting (not even user) iirc.

TomTom
  • 61,059
  • 10
  • 88
  • 148
  • 1
    There is a system-wide setting that tells Windows that your handler (exe) exists, and another setting in HKCU that sets the preference for your user. – Matthew Kennedy Oct 14 '12 at 21:18
  • But both are not application specific. Which makes sense - the user chooses a web browser. Live with the choice. – TomTom Oct 15 '12 at 04:59
  • 1
    This is possible, all major browsers can set themselves as default. – msbg Oct 17 '12 at 20:42
  • @msbg No, they can not. I suggest reading sentences or articles front to end - makes you a better Person. They can set themselves as Default browser SYSTEM WIDE or USER WIDE, but NOT FOR A SPEFICIFC APPLICATION. Maybe you do not understand english well enough to read the question? He asks specifically application specific (when you click a Hyperlink in application X, use Chrome, not the System Default). – TomTom Oct 18 '12 at 04:09