Setting a default Firefox profile
Posted on Mon 11 April 2011 in tools
Twice on the same week. I'm getting better at not seeing the obvious. Or maybe I'm right saying that it was not that obvious in this case. Ok, less ranting and more to the point.
If you use more than one profile in Firefox, you may end up having the wrong environment settings, which cause your system to open new URLs (those associated with FF anyway) in one of the other "not default" profiles, effectively bringing up another Firefox instance when you already have your "default" one up. And that can be annoying. It's really easy to change though, keep reading.
If you just want the solution, go to the list at the bottom of the post.
We are in an environment with more than 1 Firefox profile, and we bring each one of them up with our --no-remote -P "[prof_name]"
arguments. All fine there. Now, to your surprise, when you click on a link in
another app or simply open an .html file, one of the new profiles is used, instead of your main Firefox profile, which you even have open. I don't want to have to copy and paste links, or have more than one Firefox instance if I'm not developing, so let's see how to fix this.
I googled "default firefox profile open", "firefox default multiple profile", and so on, but they all led me to how to setup profiles in Firefox or similar, not useful. The Mozilla support pages were interesting but not right what I was looking for. Before asking in the forums, I wanted to give it a go on my own to see how this was working, so I started looking at the Firefox command line options, the full list.
So how does windows know which Firefox to use? I can smell registry settings a mile away. It turns out, as explained somewhere in the Mozilla site, that all shell open of a .html, .htm and others is a redirect to the registry Class "FirefoxHTML", which in turn opens Firefox with a neat command:
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -requestPending -osint -url "%1"
I thought: "cool, now I'll add my --no-remote -P "default"
and we're all set". Well, not quite. It turns out the command arguments in that line have some history and reasoning behind, and you can't just add your parameters in there. It's got to do with security issues, take a look at this Mozilla Bug if you're interested. It's basically that -osint
prevents running command line arguments other than -requestPending
and -url
to prevent running arbitrary code from a shell open operation.
So I had to try something different. All of these shell open/execute launch a specific, predetermined profile, it's not random. Therefore it sounds like it's Firefox the one controlling this. Let's take a look at the profile's configuration file.
In my case, Default=1
was within the element Profile1
, which referred to a secondary profile. That was the reason causing this to be the profile chosen when a new URL was open. Great.
Now there are two ways to change this. As this file is managed by the profile manager, you can either run the profile manager or change the configuration file profile.ini
yourself. I went for the easy one while
keeping an eye on the changes in profile.ini
. To get the profile manager, run firefox.exe -P
It's as simple as selecting the one you want to be the default (don't be confused by me having one profile named "default") and selecting "Don't ask at startup". Then click Start Firefox and that will be your default
profile from now on. This is how my profiles.ini
file resulted after performing this change. Note how before doing this, Default=1
was within Profile1
.
And that's it. Now all files and protocols associated with Firefox run from the shell will open your default profile, the one with Default=1
in profile.ini
. Summing up, these are the steps to set which one is
going to be your default Firefox profile:
- Close all firefox instances.
- Reset
StartWithLastProfile
in%APPDATA%\Mozilla\Firefox\profiles.ini
to 0 or runfirefox.exe -P
- Profile chooser comes up.
- Select desired profile to set as default and check "Don't ask at startup".
- Done!