1

I have a small python program that takes a URL and sends it to a neighbouring machine, which has a server that receives URLs and opens them in the browser.

My next step is to register this python program as the default browser in the local Windows box so that it gets the URLs when I click on links anywhere (Chat software, email clients, other applications).

How does one register a custom application as the default Web browser in windows?

Additional questions: What are the minimum requirements for this? Can I revert it back to the previous value? Is there a python library for that?

Jacobo de Vera
  • 1,863
  • 1
  • 16
  • 20
  • did googling not work? You can compile your python program into an exe then setting it should work fine – Sasha Apr 26 '18 at 13:04
  • What do you mean by "click on them anywhere"?... If you then click on them and you registered another application than the standard web browser, the latter cannot open the link. Maybe you are better looking for a plugin to your web browser. – Sven-Eric Krüger Apr 26 '18 at 13:20
  • @SvenKrüger I edited the question, hope it is clearer now. The idea is that the local browser is never used. – Jacobo de Vera Apr 26 '18 at 13:22
  • @Jaxi I am asking about how to set this programmatically, preferably. I see that all browsers have this option to set themselves as the default browser. That is what I am trying to accomplish. So is being a exe a requirement for this? – Jacobo de Vera Apr 26 '18 at 13:24
  • For windows i'm pretty sure it is, or if you want to do it very easy just replace the EXE of the current default – Sasha Apr 26 '18 at 13:27
  • @Jaxi I see, I hadn't thought of that, but I would still like to do in a more *proper* way – Jacobo de Vera Apr 26 '18 at 13:31
  • Ah, i'm afraid this is the only way i've thought of, hopefully someone else may be able to assist – Sasha Apr 26 '18 at 14:14
  • I have not tested that but you can browse through your Windows Registry to `HKEY_CURRENT_USER/Software/Classes/http/shell/open/command` and then change the value to `python "C:\path\to\your_script.py" "%1"`. I would suggest the same for https... But again: this might corrupt your web browser. – Sven-Eric Krüger Apr 26 '18 at 15:30

1 Answers1

2

The answer depends on the version of Windows. In the olden days, you had to tinker in the registry. In newer versions, you could change the http protocol association with an interface or two. Then you could only propose an association through a different API and get the user to take action to confirm it. In the newest versions of Windows, they've made it virtually impossible to change certain kinds of defaults to protect the users from a war of defaults being waged by competing applications.

If this is a one-off, I would just set it manually through the Default Programs control panel applet that's included in current versions of Windows.

If you want to attempt it programmatically, this seems like a good entry point into the documentation.

Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175