26

I use multiple browsers regularly, so I've written a script that will open pages in whatever browser is already running (or Firefox if there is none). I want to set this script as my default browser. When I go to the "Set Associations" dialog, select HTTP, and click "Change Program", the dialog that pops up doesn't allow me to select anything except one of the web browsers that I already have installed. This appears to be the case for all protocols (as opposed to file extensions, which allow you to choose from "Other Programs" or browse for a program that isn't listed). Windows help says nothing about this, and just says to use the "Browse..." button, which isn't available. I even tried the 3rd-party "Default Programs Editor", but it doesn't seem to be able to do this.

Is there a way that I can set my script as the default manually (maybe by editing the registry)?

0

4 Answers 4

37

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

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

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

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

Now if you've been paying close attention, you might have noticed a couple flaws with all of this:

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

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

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

  4. 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!

3
  • 2
    Thanks for the detailed response. What would I do if I wanted to set something other than one of the installed browsers as the default HTTP handler? Is it even possible to set it to use something that hasn't already been installed to the registry? Or will I need to create a registry entry for my script?
    – Morgan May
    Commented Dec 18, 2011 at 4:40
  • 2
    @MorganMay What you'd need to do is remove the UserChoice Default Programs registration, so that the "standard" file association keys are used, as referenced in point #3. For example, look at the default value of HKEY_CLASSES_ROOT\http\shell\open\command (You can write that same key in HKEY_CURRENT_USER as a standard user, if that matters). Should just be a matter of setting the application path and whatever parameter string your browser needs (eg, -- %1 I think for Chrome) Commented Dec 18, 2011 at 20:59
  • 1
    Glad I read till the end. The combination of removing the ProgId entries, and then setting the "default" handler in HKCR\http\shell\open\command
    – Brent
    Commented Mar 14, 2017 at 21:48
0

Posting because this is still relevant today on Windows 10.

I see other answers talking about the registry. This is handy and all but it's very painful to do by hand. Therefore I want to submit my own registry configuration (At the bottom of this answer) which takes away all the stuff that you have to do yourself! I made this one because I wanted to use the "Ungoogled Chromium" browser as default but there wasn't a proper installer available to add the application to the list of available browsers.

Save the .reg file to your PC and then perform the following steps:

  • Edit the path in the .reg file to match the path to your own application. Mine is "C:\Program Files\Ungoogled Chromium\chrome.exe" (Taken from the .reg file). Make sure that it's properly escaped!
  • Import the .reg file.
  • Optional: Place a shortcut in %Appdata%/Roaming/Microsoft/Windows/Start Menu/Programs pointing to your browser.

The only problem I have is that for some reason Chromium will keep saying that it's not the default browser, even after making it the default. After I've installed Chrome and switched back to Chromium, the message was gone. It's back after switching to IE and then back to Chromium. I don't know why unfortunately, but just disable the warning. It seems like it all works fine.

After correctly importing the registry file, the browser will appear in the list of applications to choose from. Default Applications List

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\UngoogledChromium\Capabilities]
"ApplicationDescription"="Chromium without Google's phone home."
"ApplicationIcon"="\"C:\\Program Files\\Ungoogled Chromium\\chrome.exe\",0"
"ApplicationName"="Ungoogled Chromium"

[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\UngoogledChromium\DefaultIcon]
@="C:\\Program Files\\Ungoogled Chromium\\chrome.exe,0"

[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\UngoogledChromium\Capabilities\FileAssociations]
".crx"="UngoogledChromium"
".htm"="UngoogledChromium"
".html"="UngoogledChromium"
".nex"="UngoogledChromium"
".pdf"="UngoogledChromium"
".shtml"="UngoogledChromium"
".xht"="UngoogledChromium"
".xhtml"="UngoogledChromium"

[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\UngoogledChromium\Capabilities\Startmenu]
"StartMenuInternet"="UngoogledChromium"

[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\UngoogledChromium\Capabilities\UrlAssociations]
"http"="UngoogledChromium"
"https"="UngoogledChromium"
"ftp"="UngoogledChromium"
"mailto"="UngoogledChromium"


[HKEY_CURRENT_USER\Software\Classes\UngoogledChromium]
"FriendlyTypeName"="Chromium Web Document"
"URL Protocol"=""

[HKEY_CURRENT_USER\Software\Classes\UngoogledChromium\DefaultIcon]
@="C:\\Program Files\\Ungoogled Chromium\\chrome.exe,0"

[HKEY_CURRENT_USER\Software\Classes\UngoogledChromium\shell]

[HKEY_CURRENT_USER\Software\Classes\UngoogledChromium\shell\open]

[HKEY_CURRENT_USER\Software\Classes\UngoogledChromium\shell\open\command]
@="\"C:\\Program Files\\Ungoogled Chromium\\chrome.exe\" -- \"%1\""
-1

If there's anyone else that landed on this answer while looking to set something custom as a default protocol handler in Windows 10, I think I've cracked it.

The other answer to this question got me a step closer with the Clients\StartMenuInternet key, that I didn't know about for setting the default browser in Windows 7. However, after pretty much duplicating Firefox's StartMenuInternet key, my program still wasn't appearing in the Settings app.

After using Revo Uninstaller to start an uninstall of firefox, cancelling firefox's uninstaller then letting Revo scan for leftover registry keys, I found another key: HKLM\SOFTWARE\RegisteredApplications. This seems to store all the programs registered that windows can be told about their functionality.

So after setting up the StartMenuInternet key, add a key in HKLM\SOFTWARE\RegisteredApplications to point to Software\Clients\StartMenuInternet\YOURPROGRAM\Capabilities - yes, exactly like that, starting with Software\:

Screenshot of regedit (I can't embed the image until I have 10 rep...)

-1

In order for your program (YName.exe) to be considered a browser, it needs to be registered:

1) ...StartMenuInternet - as described above,

HKCU\Software\Clients\StartMenuInternet\YName\Capabilities\URLAssociations

http=YNameURL

https=YNameURL

2) HKCU\Software\RegisteredApplications - as described above:

YName=Software\Clients\StartMenuInternet\YName\Capabilities

3) HKCU\Software\Classes\YNameURL\shell\open\command

@=Path\YName.exe

4) HKCU\Software\Classes\Applications\YName.exe\shell\open\command

@=Path\YName.exe


2
  • 1
    Welcome to Super User! Please note that answers must be in English (entirely).
    – Glorfindel
    Commented Mar 23, 2019 at 16:26
  • (1) Super User is an English-only site.  Please delete the parts of your answer that are not in English. (2) Every answer should be able to stand (make sense) by itself. This one does not. Answers should not say “as described above” in reference to other answer(s). Please edit this so it makes sense by itself. It’s OK to copy parts of other answers as long as you give credit. (3) Most of what this says seems to have been said already. Please make it clear what new information you are adding. Commented Mar 23, 2019 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .