Search code examples
c#wpfhttpregistrydefault-browser

How to set the default browser to my application?


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.


Solution

  • 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.