我希望通过脚本(VBS 或批处理)配置以下 Firefox 设置
- 默认主页
- 默认搜索引擎
- 禁用自动更新
这可能吗?
答案1
您可以通过以下方式进行创建或操作 Mozilla 首选项文件使用您喜欢的脚本语言。
有关可通过这些文件设置的首选项列表,请参阅Mozilla 偏好设置和关于:配置文档,尽管与您的列表相对应的文档似乎是:-
browser.startup.homepage
(默认主页)browser.search.defaultenginename
(默认搜索引擎)app.update.auto
(启用/禁用自动更新)
但是,根据您的环境,您可能会发现通过自定义插件推送设置会更好(请参阅Mozilla 偏好设置简介)或通过 GPOFirefoxADM或类似的东西。
答案2
您可以在用户配置文件文件夹中的 user.js 文件中覆盖私人浏览器选项。我经常使用它来覆盖某些选项,例如管道。更新 user.js 后,需要重新启动 Firefox。如果文件 user.js 不存在,则必须创建一个。
答案3
直接复制/粘贴我正在寻找的答案部分(win env.)
'C:\Users\User\AppData\Roaming\Mozilla\Firefox\Profiles\#####.default\prefs.js'
添加
user_pref("browser.startup.homepage", "http://www.URL");
我尝试使用 Get-Content/cat string.txt/"String" >> path 将其复制到远程机器,但prefs.js
由于字符串中的转义字符,最终导致垃圾被插入到文件中。
答案4
这个帖子有点老了,但我还是想分享我的解决方案。希望这对某人有帮助。我们遇到了类似的问题,想将 Windows 商店的证书添加到 Firefox 中。所以我创建了一个脚本来执行此操作。无论如何,您可以根据需要进行更改:只需在 :: create cfg_file_name.cfg[...] 处添加或删除行并插入您需要的内容,例如开始主页等。请记住在最后一个 ) 之前设置 ^,否则它将不起作用!echo pref("browser.startup.homepage", "http://superuser.com"^);
从版本 49 开始你可以这样做:
@echo off
setlocal enabledelayedexpansion
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: MAIN INFORMATION
:: Title: Change about:config entries in Mozilla Firefox
:: Author: I-GaLaXy-I
:: Version: 1.1
:: Last Modified: 10.01.2018
:: Last Modified by: I-GaLaXy-I
::------------------------------------------------------------------------------
:: This script will add two files, which will change about:config parameters of
:: Mozilla Firefox. You can change the name of these two files and remove or add
:: parameters according to your needs. Renaming the files could be essential, if
:: a user creates own files and you don't want to overwrite them.
::
:: If the two files already exist and the script is run, the complete content
:: of both files will be overwritten!
::
:: Note: You may have to run it with administrative privileges!
::
:: More information: https://developer.mozilla.org/en-US/Firefox/Enterprise_deployment
:: http://kb.mozillazine.org/Locking_preferences
::------------------------------------------------------------------------------
:: Subtitle: Import CAs from Windows certificate store
:: More information: https://serverfault.com/questions/722563/how-to-make-firefox-trust-system-ca-certificates
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set the name of the .cfg file
set cfg_file_name=add_win_certstore_cas
:: Set the name of the .js file
set js_file_name=add_win_certstore_cas
:: Registry keys to check for the installation path of Mozilla Firefox
set regkey1="HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\Windows\CurrentVersion\App Paths\firefox.exe" /v "Path"
set regkey2="HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE\shell\open\command" /ve
:: Get installation path of Mozilla Firefox (if not found exit script):
reg query %regkey1%
if %errorlevel%==0 (
:: First key found, getting path
for /f "tokens=2* delims= " %%a in ('reg query %regkey1%') do set path_firefox=%%b
) else (
:: If first key not found, try another one:
reg query %regkey2%
if !errorlevel!==0 (
for /f "tokens=2* delims= " %%a in ('reg query %regkey2%') do set path_firefox=%%b
set path_firefox=!path_firefox:\firefox.exe=!
for /f "useback tokens=*" %%a in ('!path_firefox!') do set path_firefox=%%~a
) else (
:: No key found, exit script
exit
))
:: Create cfg_file_name.cfg if it doesn't exist and input the following lines.
:: Caution! If cfg_file_name.cfg already exists, all lines will be overwritten!
:: Add more lines as needed with the following syntax:
::echo pref("<name_of_config_entry>", <value>^);
(
echo //Firefox Settings rolled out via KACE from Systec
echo //Do not manually edit this file because it will be overwritten!
echo //Import CAs that have been added to the Windows certificate store by an user or administrator.
echo pref("security.enterprise_roots.enabled", true^);
) > "%path_firefox%\%cfg_file_name%.cfg"
:: Create js_file_name.js if it doesn't exist and input the following lines.
:: Caution! If js_file_name.js already exists, all lines will be overwritten!
(
echo /* Firefox Settings rolled out via KACE from Systec
echo Do not manually edit this file because it will be overwritten! */
echo pref("general.config.obscure_value", 0^);
echo pref("general.config.filename", "%cfg_file_name%.cfg"^);
) > "%path_firefox%\defaults\pref\%js_file_name%.js"
:: Files created, exit
exit