有没有命令行参数可以强制firefox.exe为特定URL启动一个新进程,而不管是否已经运行了另一个firefox实例?
有没有命令行参数可以强制firefox.exe为特定URL启动一个新进程,而不管是否已经运行了另一个firefox实例?
firefox.exe -no-remote -p sidekick
然而,如果该配置文件已被当前Firefox会话使用,则此方法无效。
若要创建新的配置文件,请在命令行中使用-P标志启动Firefox并创建它。
firefox.exe -P
在2020年10月,三年后,问题提出者ykaganovich在评论中指出:
最近的Firefox版本(截至2020年)还可以通过
about:profiles
访问配置文件管理UI界面。
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 ==================
用于打开第二个应用程序的火狐浏览器的脚本。这与上面的脚本相同。
将其复制并保存到另一个文件中,例如 secondfirefox.bat。在另一个文件夹中安装 FirefoxPortable,例如 C:\portables\SecondFirefoxPortable。更改 secondfirefox.bat 中的变量以指向其他便携式 Firefox 安装文件夹。
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 ---
---- 更新 ----
修复了错误 - 更正了个人资料路径。
分离出用于清除密码的变量。在我的网页应用程序的登录页面上记住密码。减少输入。
---- 更新 ---- 2014-10-01
不再需要手动重命名FirefoxPortable.exe文件。脚本会在FirefoxPortable安装的第一次运行时完成此操作。
---- 更新 ---- 2014-11-09
更改以允许通过运行FirefoxPortable安装程序进行更新。当此批处理程序要求您覆盖首选项和书签时,请键入N。这将保留书签和某些设置。
启动新进程(实例)的方法是
-new-instance
Open new instance, not a new window in running instance, which allows multiple copies of application to be open at a time.firefox -new-instance -P "Another Profile"
Note: Not available for Windows, see bug 855899.
如果你使用的是Mac电脑,你可以使用以下命令每次打开一个新的实例并创建一个全新的空白配置文件:
open -n -a Firefox.app --args -profile `mktemp -d /tmp/fx-profile.XXXX` -no-remote -new-instance