Yes, you can script it with direct registry manipulation.
The Short Answer
Copy each of the following into .reg
files (such as firefox.reg
, chrome.reg
, ie.reg
) and run them when you want to switch (or, script with reg.exe
).
For Firefox:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice]
"ProgId"="FirefoxURL"
For Chrome:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice]
"ProgId"="ChromeHTML"
For IE9:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice]
"ProgId"="IE.HTTP"
The Long Answer
Windows stores per-user standard protocol Default Registrations under the UrlAssociations
key, found at
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations
Similar to file associations, there can be a "Default Program" for links. This is sort of jargon terminology that references the UserChoice
key- there is also a standard file association-like shell registration under the http
ProgId which can also be changed, but the proximal configuration for browsers is via Default Programs (see bottom for an additional comment on this).
What I'm talking about here is what you're changing when you go to the Default Programs section of the Control Panel to set a browser:
![Default Programs for Protocols in the Control Panel](https://i.imgur.com/DehDA.png)
To configure this directly in the registry, let's first inspect that's already there. In this screenshot I've navigated to that key in regedit.exe
, and Chrome is my default browser, designated by the ChromeHTML
ProgId value.
![Navigating to the UrlAssociations subkey in regedit](https://i.stack.imgur.com/Gm8jb.png)
The minimum change you need to make to switch which browser opens when you click a link is to change the ProgId
value under the UserChoice
subkey on each protocol you want to change (probably http
and https
will be the same, but if for some reason you wanted to make each of those open in separate browsers, you could).
Now it's just a matter of determining what to use for Firefox, IE, and any other browser you may want to switch to. If you wanted to determine this programmatically, you could do so by digging into the Capabilities
key of the browser registration, found here for Firefox:
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE\Capabilities\URLAssociations
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
is where all the browsers are listed, and each one should have the above structure.
![Navigating to the Capabilities key in regedit](https://i.stack.imgur.com/TBcON.png)
You can see from inspection that if I wanted to switch to Firefox, I'd use the FirefoxURL
ProgId value back up in UrlAssociations.
(However, if you didn't want to dig around like this, there's a quick cheat: Just set whatever browser you want as default, and refresh regedit to see what the browser has set for the UserChoice
!)
All we need to do is change that key value to FirefoxURL
, and now links open in Firefox. After doing so you can either click a link or double check in the control panel that the right default is registered:
![Double checking the default program in the Control Panel](https://i.stack.imgur.com/DFVxE.png)
Now if you've been paying close attention, you might have noticed a couple flaws with all of this:
IE doesn't have a URLAssociations
subkey under it's browser registration in StartMenuInternet
, so where does the ProgId value come from? Answer: I don't know, at least not without more research. It may be hardcoded or found in another key I haven't found yet.
Firefox's ProgId's under it's URLAssociations
are FirefoxURL
, but when you click to register in the options in the browser itself, it uses FirefoxHTML
as the ProgId instead! Why? Again, I don't know. They both work because they both exist and point to Firefox. Maybe it's intentional, but it's probably just a bug with no effect.
What happens when there's no UserChoice
Default Program? Answer: the "regular" file association for the protocol (eg, http
) is used. This is found at the standard ProgId locations just like file associations (HKCU\Software\Classes
, HKLM\Software\Classes
, and the view at HKCR
). At least Chrome sets it's info there, I think, but Firefox doesn't seem to, at least in my tests.
I recommend that if you want this added to Default Programs Editor, you should suggest and upvote it on that application's UserVoice Feedback page. I have it on good authority that the application author pays attention to that feedback when deciding how to spend his development time!
There is software available that would fix the issue, but here's a manual routine you can do that will also work.
This technique is not limited to making your web browser default, but can be used for everything in the Settings page and more, as long as you know at least one file extension your program can open.
1. Show extensions for all filetypes
It is important that extensions are shown for all filetypes. To enable this, open a file explorer window, go to the tab View, and at the right check [v] File name extensions
2. Create a temporary file with .htm extension
Now, if you haven't needed to do step 1 or already closed the file explorer, open a file explorer. Navigate to any folder where you have write permissions. You can actually also use your desktop if you find that easier.
Right click, choose New > Text file to create an empty textfile.
Rename the file to temp.htm
The temp part is not so much important, but make sure the file ends with .htm
. Click Yes on the question if you are sure to change the filetype.
3. Create a new file association for .htm files
Right click your .htm file and go to Open With > Choose another app
NOTE: It may very well be that your app is listed in this list. If so, still choose Choose another app.
In the next window, at the bottom, there's a checkbox labelled [v] Always use this app to open .htm files.
. Make sure its checked.
If your program is at the top list, select it there. If not, scroll to the bottom where it says Choose an app from your pc
. This opens a file open dialog, allowing you to browse to the program on your harddrive.
When you press OK, all .htm files are now opened by your browser of choice, but this does not set your browser as default.
4. Set your browser as default
Step 3 did not just assign your browser to open .htm files, but it fixed the registry item, causing your browser to be selectable in the Settings screen Set default app. If you now go to Start > Settings > System > Default Apps, you will be able to select your browser as default web browser.
Best Answer