Is there a way to force Firefox to launch in a new process?
I often need to close multiple instances, clear the cache and open multiple firefox windows when testing my changes after rebuilding my web application. I use firefox portable for this purpose to allow multiple instances. I have written below batch scripts which modify a FirefoxPortable installation if not yet modified, stop current firefox process and restart it. I normally have four instances running with a different executable name. One for my regular browsing, and the other three for testing web apps. Very useful when you want to test and certify your web app for current and previous versions of Firefox.
I may open three tabs in the same browser, but I tend to be paranoid when dealing with browsers. I prefer to clean and re-open a fresh instance of the browser for different applications before re-testing instead of F5 or Ctrl F5.
The script will run a separate firefox portable process with a separate process name and a separate profile.
Hope these help you. Feel free to use them. Please post back your modifications and bug fixes on this thread.
Install FirefoxPortable to folder named FirstFirefoxPortable (or any other appropriate name)
REM ==============
setlocal
set URL=%1
REM FirefoxPortable installation folder
set FIREFOX_PORTABLE_HOME=C:\portables\FirstFirefoxPortable
REM Name of the FirefoxPortable executable file
set FIREFOX_FILENAME_NOEXT=FirstFirefoxPortable
REM Name of the Firefox executable file within App/firefox
set FIREFOX_EXEC_NOEXT=firstfirefox
set FIREFOX_PORTABLE_EXEC=%FIREFOX_PORTABLE_HOME%\%FIREFOX_FILENAME_NOEXT%.exe
REM Name of the other profile folder.
set FIREFOX_PROFILE=firstprofile
set CLEAR_HISTORY=true
set CLEAR_CACHE=true
set CLEAR_SAVED_PASSWORDS=true
set CLEAR_SESSION=true
set WAIT_DURATION=4
set ADDITIONAL_WAIT_DURATION=2
if not exist %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini (
@echo off
echo.
echo.
echo Setting up Firefox Profile
echo.
echo.
pause
@echo on
echo [FirefoxPortable]>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo FirefoxDirectory=App\firefox>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo ProfileDirectory=%FIREFOX_PROFILE%\profile>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo SettingsDirectory=%FIREFOX_PROFILE%\settings>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo PluginsDirectory=%FIREFOX_PROFILE%\plugins>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo FirefoxExecutable=%FIREFOX_EXEC_NOEXT%.exe>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo AdditionalParameters=>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo LocalHomepage=>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo DisableSplashScreen=false>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo AllowMultipleInstances=false>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo DisableIntelligentStart=false>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo SkipCompregFix=false>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
echo RunLocally=false>>%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini
rem create dirs
pushd %FIREFOX_PORTABLE_HOME%
mkdir %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%
mkdir %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile
mkdir %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\settings
mkdir %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\plugins
popd
rem copy profile
xcopy /e %FIREFOX_PORTABLE_HOME%\App\DefaultData\profile %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile
copy /y %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%.ini %FIREFOX_PORTABLE_HOME%\FirefoxPortable.ini
rename %FIREFOX_PORTABLE_HOME%\FirefoxPortable.exe %FIREFOX_FILENAME_NOEXT%.exe
rename %FIREFOX_PORTABLE_HOME%\App\Firefox\firefox.exe %FIREFOX_EXEC_NOEXT%.exe
)
rem check if firefox is running
REM tasklist /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe" 2>NUL | find /I /N "%FIREFOX_FILENAME_NOEXT%.exe">NUL
REM if "%ERRORLEVEL%"=="0" (
REM echo Firefox running
REM taskkill /t /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
REM ping -n 4 127.0.0.1 > NUL
REM tasklist /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
REM echo retrying killing Firefox
REM taskkill /f /t /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
REM ping -n 2 127.0.0.1 > NUL
REM taskkill /f /t /FI "IMAGENAME eq %FIREFOX_EXEC_NOEXT%.exe"
REM ) else (
REM echo Firefox not running.. starting..
REM )
taskkill /t /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
ping -n %WAIT_DURATION% 127.0.0.1 > NUL
echo ==== try killing
tasklist /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
tasklist /FI "IMAGENAME eq %FIREFOX_EXEC_NOEXT%.exe"
taskkill /t /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
taskkill /t /FI "IMAGENAME eq %FIREFOX_EXEC_NOEXT%.exe"
ping -n %ADDITIONAL_WAIT_DURATION% 127.0.0.1 > NUL
echo ==== retry killing forcefully
tasklist /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
tasklist /FI "IMAGENAME eq %FIREFOX_EXEC_NOEXT%.exe"
taskkill /f /t /FI "IMAGENAME eq %FIREFOX_FILENAME_NOEXT%.exe"
taskkill /f /t /FI "IMAGENAME eq %FIREFOX_EXEC_NOEXT%.exe"
REM clear everything - delete profile
REM del /f /s /q %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\*
REM rmdir %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\
REM mkdir %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\
REM clear all sqlite files
rem for /d %%x in (%FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\*) do del /q /s /f %%x\*sqlite
if "%CLEAR_HISTORY%"=="true" (
echo.
echo Clearing History
echo.
rem clear history (Bookmarks, browsing and download history)
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\places.sqlite*
rem clear form history (Saved form data)
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\formhistory.sqlite*
)
if "%CLEAR_SESSION%"=="true" (
echo.
echo Clearing browsing session
echo.
rem clear previous browsing session
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\sessionstore.js
)
if "%CLEAR_SAVED_PASSWORDS%"=="true" (
echo.
echo Clearing saved passwords
echo.
rem clear saved passwords
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\logins.json
)
if "%CLEAR_CACHE%"=="true" (
echo.
echo Clearing cache
echo.
rem clear permissions (Permission database for cookies, pop-up blocking, image loading and add-ons installation.)
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\permissions.sqlite*
rem clear content preferences (Individual settings for pages.)
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\content-prefs.sqlite*
rem clear cookies
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\cookies.sqlite*
rem clear cache
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\cache2\*
rem clear offline cache
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\OfflineCache\*
rem clear DOM Storage
del /q /s /f %FIREFOX_PORTABLE_HOME%\%FIREFOX_PROFILE%\profile\webappsstore.sqlite*
)
if "%URL%"=="" (
set URL=www.google.com?q=DidYouPassTheURLArgument
)
@echo on
start /MAX "%FIREFOX_FILENAME_NOEXT%.exe" %FIREFOX_PORTABLE_EXEC% -P "%FIREFOX_PROFILE%" -no-remote -new-tab %URL%
endlocal
REM ==================
Script for opening firefox for the second app. It is the same script as above.
Copy and Save in a separate file e.g. secondfirefox.bat. Install FirefoxPortable in another folder e.g. C:\portables\SecondFirefoxPortable. Change the variables in secondfirefox.bat to point to the other portable firefox install folder.
setlocal
set URL=%1
REM FirefoxPortable installation folder
set FIREFOX_PORTABLE_HOME=C:\portables\SecondFirefoxPortable
REM Name of the FirefoxPortable executable file
set FIREFOX_FILENAME_NOEXT=SecondFirefoxPortable
REM Name of the Firefox executable file within App/firefox
set FIREFOX_EXEC_NOEXT=secondfirefox
set FIREFOX_PORTABLE_EXEC=%FIREFOX_PORTABLE_HOME%\%FIREFOX_FILENAME_NOEXT%.exe
REM Name of the other profile folder.
set FIREFOX_PROFILE=secondprofile
REM --- snip ---
---- Update ----
Bug fixes - corrected the profile path.
Separated out variable for clear passwords. Remember password for the login page of my web app. Less typing.
---- Update ---- 2014-10-01
Removed the need to manually rename the FirefoxPortable.exe file. The script does it on first run of FirefoxPortable installation.
---- Update ---- 2014-11-09
Changes to allow updating by running the FirefoxPortable installer. When this batch asks you to overwrite the prefs and bookmarks, type N. This will preserve bookmarks and some settings.
Yes, as detailed in Firefox Command Line Arguments:
firefox -new-window
Edit: re-reading you actually said "process", in which case no, I don't think you can.
If you have a second profile (like 'sidekick'), the following will launch a new Firefox process:
firefox.exe -no-remote -p sidekick
However, if that profile is already used by a current Firefox session, that will not work.
To create a new profile launch Firefox from the command line with the -P flag and create it.
firefox.exe -P
The OP ykaganovich adds in the comments (in Oct. 2020, three years later):
recent versions of Firefox (as of 2020) also have profile management UI available at
about:profiles