I want to switch between two firefox profiles online using bat file without closing my firefox. Is it possible? thanx in advance.
Profiles says:
"Firefox saves your personal information such as bookmarks, passwords, and user preferences in a set of files called your profile, which is stored in a separate location from the Firefox program files."
I don't think that is possible. Firefox reads files from the profile directory at start-up and writes them back when quit. If you would do it by hand you still need to tell Firefox to read the initialization files again. This could mess up all the profiles at the end I guess.
Why would that make sense? What do you want to do w/ it?
You can't switch profiles without restarting Firefox.
However, you can run several copies of FF with different profiles simultaneously. I don't know what is your goal, but maybe this can help?
Command line:
firefox -P <profile-name> -no-remote
Be careful not to run more than one instance of Firefox with same profile. The -no-remote switch prevents a Firefox instance from knowing about other instances. If multiple instances access the same profile simultaneously, the profile can be corrupted.
Related
I would like to restore not the last "Restore Previous Session".
Open firefox (v78.0) with few tabs: aaa.com, bbb.com.
Close Firefox.
Open Firefox, open few tabs, ccc.com, ddd.com.
Close Firefox.
Open Firefox. How to get those tabs aaa.com, bbb.com from "Restore Previous Session"?
I went to the address bar of Firefox, typed about:support and saw which is the profile folder of Firefox.
I figured out that some versions of Firefox create a
c:\Users\MY_USER\AppData\Roaming\Mozilla\Firefox\Profiles\j1hcxbyk.default-release\sessionstore.jsonlz4 file when Firefox is closed.
I also found a copy of a session file
c:\Users\MY_USER\AppData\Roaming\Mozilla\Firefox\Profiles\j1hcxbyk.default-release\sessionstore-backups\upgrade.jsonlz4-20200630195452
So, I:
stopped Firefox,
made a back-up copy of the profile folder,
replaced sessionstore.jsonlz4 (or copied there if that file didn't exist) with upgrade.jsonlz4-20200630195452,
started Firefox,
restored the previous session with: Menu->History->Restore Previous Session,
checked that the old session, with my tabs, was restored.
Note: I chose upgrade.jsonlz4-20200630195452 because it was created in the same day, when I closed Firefox with all my tabs.
Recently, I faced the same issue of missing tabs when I restored the correct system date from some earlier date. After scouring the internet, I got the following tip to restore the firefox tabs back from saved sessions. My PC runs Microsoft Windows 10 Home with Firefox version 91.0.
Reference: https://support.mozilla.org/en-US/questions/1314940
"At startup, Firefox usually will look first for sessionstore.jsonlz4 at the main level of your profile folder and if it finds it, use its contents to create recovery.jsonlz4 -- if you restore automatically -- or previous.jsonlz4 -- if you do not restore automatically. So you could try replacing that file if you haven't already (as well as recovery.jsonlz4)".
Close the firefox browser.
Open %AppData%/Mozilla/Firefox/Profiles folder
Select the latest folder that contains .default in it.
Open sessionstore-backups folder. Now your path would be something like %AppData%\Mozilla\Firefox\Profiles\13dn9aq1.default-1473265690957-1560267471460\sessionstore-backups
Locate files with upgrade.jsonlz4- prefix and select the one which you think probably would contain your tabs.
Keep the original one untouched. Create a copy of it and rename it to sessionstore.jsonlz4
Copy the sessionstore.jsonlz4 file. Locate the sessionstore.jsonlz4 file in the folder one level down: %AppData%\Mozilla\Firefox\Profiles\13dn9aq1.default-1473265690957-1560267471460\ and replace it with the sessionstore.jsonlz4 file just copied.
Now you can open Firefox and you will get all your old tabs from the restored session.
The folder .default. can be located as follows also,
Type "about:profiles" in firefox and press enter
Click "Open Folder " next to Root Directory path
I had the same issue, and Firefox wouldn't read the *.jsonlz4 files properly, so I coded a little script to extract the URLS stored inside *.jsonlz4 files:
https://github.com/matthieuheitz/recover-firefox-session
Some people use this tool: https://www.jeffersonscher.com/ffu/scrounger.html, but it didn't work for me as the *.jsonlz4 files were very large (> 50MB), and the website just lags forever.
Recent Firefox version (version 96 this time, or at least the Linux one) doesn't have sessionstore.jsonlz4 in the root of the profile, so the other advices does not seem to work.
Firefox nightly upgrades a lot, so I have a very good chance to have FF restarted and lose all the session with no "restore session" available at all.
The solution (for me at least) was
stop Firefox
go to session backup directory at ~/.mozilla/firefox/<session_name>/sessionstore-backups/
copy any old file over recovery.jsonlz4 (say, cp upgrade.jsonlz4-20211112213406 upgrade.jsonlz4-20211112213406)
start firefox, and let it automagically restore th old session
It seems firefox only stores only the last previous.jsonlz4 there apart from upgrades, so it may be useful to ask cron to make periodical backups of recovery.jsonlz4 or similar.
I want to create a new profile with an addon preinstalled.
What works:
run firefox a first time.
add the addon.xpi to profile/extensions/addon.xpi.
edit profile profile/extensions.ini and add Extension0=/full/path/to/extension.xpi.
start firefox again.
What i need:
add the addon to profile/extensions/addon.xpi.
edit extensions.ini or something similiar.
use only relative paths, if possible (seems not to be implemented for extensions.ini)
Finally i want to create a zip file with some firefox preferences/addons, which can be unziped into a profilefolder to create a fresh profile with some preinstalled stuff. For this, it would be important, that everything works with relative paths. If it is definitely not possible, i can add some script to it. But i would prefer some "just unzip" solution.
I think it may be a bit harder, because mozilla wanted to prevent other software from adding toolbars and similiar to firefox by making external addon installation harder. What i already found is the key extensions.autoDisableScopes=0.
What you can do is open firefox with command line options. And pass the file path to your xpi file, so you don't have to mess with all this internals you are over there.
So do this:
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "C:\my.xpi"
and on launch it will open a tab and prompt to install your addon.
In the prefs.js:
pref("extensions.autoDisableScopes", 14); // 0x1 not set
See https://developer.mozilla.org/en-US/Add-ons/Installing_extensions#Disabling_install_locations
Then put the addons into extensions/myaddonid.xpi, making sure the filename is the id given in the install.rdf file inside the addon.xpi (zip-)file as <em:id>addon_id</em:id> tag.
On the next start the addons will be silently installed. Some addons needed one restart to work, at least the toolbar buttons were not added on the first start.
Not sure, if this will still work, when firefox decides to allow only addons signed by addons.mozilla.org. On the other hand, they will allow self-hosting addons, as soon as they are signed by AMO, so preinstalling addons downloaded from there will have a good chance.
I run a lot of automation using Firefox driver, and it takes a while (20-30 minutes). Naturally, while its running, I continue to work on something else.
However, while I doing things, I occasionally press the Shift key while a new Firefox instance is starting up. However, Firefox has hardcoded that it will boot in safe mode if you are holding shift, which then freezes automation in its "Are you sure you want to boot in safe mode?"
Here's the different options I've considered:
When I first ran into this, I thought that it was an issue with Firefox crashing multiple times. I changed toolkit.startup.max_resumed_crashes to 99999999 and browser.safebrowsing.enabled to false, both manually, and in my FirefoxProfile
I've tried this and this, both of which apparently refer to an old version of firefox, because the files they describe no longer exist.
This doesn't sound like it will work because profiles don't have anything to do with Safe Mode and I can't execute any AutoIt code because Selenium is still maintaining control as its frozen with the popup.
Running Firefox 3.6 or lower is not an option. Running headless is currently in the works (using Phantom), but we'll never stop running it with firefox. The same is true for the Grid (and I like running it local so I can actually see it run).
I've run into this enough times that I'm pretty desperate for any solution...whether that means changing something in my code, firefox settings, some files in the firefox folder, or even some AutoHotKey script (which I've considered, but don't know how it would work).
Thank you!
This solution you mentioned seems to work well for me even with the newest Firefox 22.
The omni.ja file is the one you want to unpack. It is a regular zip file.
Inside it:
Simply unpack, change the file, repack, save. Worked for me.
I have a shell script that creates Firefox profiles and then uses them to open multiple instances of Firefox simultaneously. The problem is how can I open a URL in a particular instance of Firefox?
I have tried
firefox -CREATEPROFILE test
firefox -P test -no-remote
firefox -P test -url www.google.ie
But the last part which is trying to open the URL using the test profile does not work, it always opens in the default profile.
Is there any way to tell Firefox from the command line to open a URL using a particular profile?
Thanks.
EDIT: I am using Linux, I don't think its possible to do what I want to do from the command line (However, Firefox command-line options are not fully documented so it could be possible). One solution to my problem would be to use JavaScript to open the tabs once the browser has been executed. I think changing the default profile to the profile I want to open each time I want to load a new URL may work also. This will require changes to profiles.ini each time a new URL is loaded. I haven't tested this but it looks promising.
Yes this can be done, Modify your profiles.ini (/home/username/.mozilla/firefox/profiles.ini) to change the default profile each time you want to open a URL in a different profile.
I know this is a bit of a pain but it works and its the only way to do this. Now I can have multiple Firefox instances/profiles open simultaneously and still open new tabs in which ever instance I want from my shell script.
YAY!
Unfortunately Firefox only supports one remote profile at a time, so all your command lines have to remote into the same process. (Mozilla Suite for Linux supported a per-profile remote, but then again it didn't support the -profile flag.)
On the other hand if you know all the URL(s) that you want to load in advance, then you can simply pass all of them on the Firefox command line, concatenated with | characters (but quoted to stop the shell interpreting them). So for instance if you want to start a new instance of the test profile opening the page www.google.ie (only), use firefox -no-remote -P test -browser www.google.ie
I have written an application suite on Windows which amongst other things installs a Firefox add-on which once run modifies the Firefox network preferences by interfacing with nsIPrefService.
The extension itself resides in a folder under Program Files along with other parts of the application which work together with each other.
Since the application consists of a number of components, the correct way to uninstall it is via the Control Panel or via an uninstall shortcut I provide for the users.
I have no control over whether Firefox will be running or not when the user chooses to uninstall (possibly I could try to detect if it's running in the uninstaller and request the user close it to continue).
Since the purposes of the uninstaller is to remove all traces of the program from the end-users system i.e:
all the files under the Program Files folder, including the extension components
remove the add-on from Firefox (by removing the registry key under HKEY_CURRENT_USER\Software\Mozilla\Firefox\Extensions, causing the add-on to unregister on next Firefox restart)
remove application specific registry keys
Then after uninstall there isn't any of my code left on the users system capable of restoring the network preferences to what they were before the component was installed. This results in end-users not being able to browse the web and being very frustrated!
The only way I can figure out how to do this at the moment is to have my component write to the window's registry the location of the users profile folder - which I can do with my add-on:
Components.classes["#mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties).get("ProfD",
Components.interfaces.nsIFile).path
And then have my uninstaller modify the prefs.js file in that location directly. But this will only work if I can guarantee Firefox isn't running during uninstall (since prefs.js is re-written on FF close)
To me this is not an elegant solution:
It seems not to be future proof since it is dependent on the format and symbols used prefs.js which may change in future FF releases.
Firefox has a nasty habbit of not always closing properlly (sometimes other installed add-ons prevent it from completely unloading from memory. This would break my uninstaller).
This wouldn't work (without elaborate modification) if the user has multiple FF profiles setup all using my add-on.
Is there a better or "standard" way to achieve this simple task?
Did you try to package defaults files (defaults/preferences/myprefs.js) in your extension? I didn't check if it works for overriding Firefox-wide defaults, but it should.
Can't the uninstaller "insist" that Firefox be closed? eg,
check if FireFox is open
if open, inform user "FF must be closed, or cancel uninstall" ok/cancel
loop
I've had several installers do this to me. Not unistallers, though, that I can remember.
Also, this doesn't future-proof the solution, nor deal with profiles.