部署Google Chrome for Business时如何自定义默认设置?


14

我希望能够在我的组织中部署Google Chrome for Business,而无需创建任何其他快捷方式,也不需要任何首次运行提示。Chrome for Business安装程序是Windows Installer文件(MSI),但它只是可执行安装程序的包装。它没有像许多MSI安装程序一样可以在msiexec命令行上设置的属性(例如CreateDesktopShortcut)。如何自定义安装?我宁愿不编写和维护安装脚本。

Answers:


24

Google Chrome 将默认的用户首选项存储在master_preferences文件中。这是JSON格式的文本文件,它包含一个distribution对象,该对象包含将在安装过程中读取的设置。在现有的Chrome安装中编辑此文件无法解决问题,因为该安装显然已经在此时进行。解决方案是使用转换文件将自定义的master_preferences文件集成到Windows Installer安装过程中。请执行以下步骤来完成此操作。

收集所需的安装程序和工具

  1. Google Chrome for Business安装程序
    我将64位版本下载到E:\Chrome for Business 38 (64-bit)
  2. 用于Windows 8.1的Microsoft Windows软件开发工具包(SDK)
    我将其下载到E:\WindowsSDK8.1
  3. 安装Windows SDK :E:\WindowsSDK8.1.\sdksetup.exe
  4. 逆戟鲸安装(Windows Installer数据库编辑器):
    msiexec /package "C:\Program Files (x86)\Windows Kits\8.1\bin\x86\Orca-x86_en-us.msi"

编写定制的master_preferences文件

  1. 查看可用的分发设置。这些是distribution对象的属性,该属性包含在master_preferences文件的匿名对象内。下面的设置列表编译通过结合两种铬源文件:master_preferences_constants.hmaster_preferences_constants.cc/主干/ src目录/铬/安装/ UTIL /。请注意,以下内容不是有效的JSON,因为属性未包含任何值。下面进一步显示一个示例。
{
  "distribution" : {
    // All the preferences below are expected to be inside the JSON "distribution"
    // block (as shown here). Some of them also have equivalent command line option. 
    // If same option is specified in master preference as well as command line, 
    // the command line value takes precedence.

    // Boolean. Use alternate text for the shortcut. Cmd line override present.
    "alternate_shortcut_text"

    // Boolean. Whether to instruct the installer to auto-launch chrome on computer
    // startup. The default (if not provided) is |false|.
    "auto_launch_chrome"

    // Boolean. This is to be a Chrome install. (When using MultiInstall)
    "chrome"

    // Boolean. This is to be a Chrome App Host install.
    "app_host"  // TODO(huangs): Remove by M27.

    // Boolean. This is to be a Chrome App Launcher install.
    "app_launcher"

    // Integer. Icon index from chrome.exe to use for shortcuts.
    "chrome_shortcut_icon_index"

    // Boolean. This is a legacy preference and should no longer be used; it is
    // kept around so that old master_preferences which specify
    // "create_all_shortcuts":false still enforce the new
    // "do_not_create_(desktop|quick_launch)_shortcut" preferences. Setting this to
    // true no longer has any impact.
    "create_all_shortcuts"

    // Boolean pref that disables all logging.
    "disable_logging"

    // Name of the dictionary that holds the distribution values.
    "distribution"

    // Boolean pref that triggers silent import of the default browser bookmarks.
    "import_bookmarks"

    // String pref that triggers silent import of bookmarks from the html file at
    // given path.
    "import_bookmarks_from_file"

    // Boolean pref that triggers silent import of the default browser history.
    "import_history"

    // Boolean pref that triggers silent import of the default browser homepage.
    "import_home_page"

    // Boolean pref that triggers silent import of the default search engine.
    "import_search_engine"

    // Integer. RLZ ping delay in seconds.
    "ping_delay"

    // String of Chrome version for which the "set as default browser" infobar will
    // never be shown.
    "suppress_default_browser_prompt_for_version"

    // Boolean. Do not show first run bubble, even if it would otherwise be shown.
    "suppress_first_run_bubble"

    // Boolean. Prevent creation of all shortcuts to chrome, including the
    // desktop, quick launch, taskbar and the start menu shortcuts.
    "do_not_create_any_shortcuts"

    // Boolean. Prevent creation of the Desktop shortcut on install (and later on
    // Active Setup for each user on a system-level install).
    "do_not_create_desktop_shortcut"

    // Boolean. Prevent creation of the Quick Launch shortcut on install (and later
    // on Active Setup for each user on a system-level install).
    "do_not_create_quick_launch_shortcut"

    // Boolean. Prevent creation of the Taskbar (since Windows 7) shortcut on
    // install (and later on Active Setup for each user on a system-level install).
    "do_not_create_taskbar_shortcut"

    // Boolean. Do not launch Chrome after first install. Cmd line override present.
    "do_not_launch_chrome"

    // Boolean. Do not register with Google Update to have Chrome launched after
    // install. Cmd line override present.
    "do_not_register_for_update_launch"

    // String.  Specifies the file path to write logging info to.
    "log_file"

    // Boolean. Register Chrome as default browser. Cmd line override present.
    "make_chrome_default"

    // Boolean. Register Chrome as default browser for the current user.
    "make_chrome_default_for_user"

    // Boolean. Expect to be run by an MSI installer. Cmd line override present.
    "msi"

    // Boolean. Support installing multiple products at once.
    "multi_install"

    // Boolean. Show EULA dialog before install.
    "require_eula"

    // Boolean. Indicates that the first-run 'set-as-default' dialog should not be
    // shown. Relevant in Windows 8+ context only. If this is true, the standard
    // 'set default browser' prompt on the butter-bar will appear during the first
    // run.
   "suppress_first_run_default_browser_prompt"

    // Boolean. Install Chrome to system wise location. Cmd line override present.
    "system_level"

    // Boolean. Run installer in verbose mode. Cmd line override present.
    "verbose_logging"

    // Name of the block that contains the extensions on the master preferences.
    "extensions.settings"
  }
}
  1. 查看可用的非分发设置。这些设置位于distribution JSON 中的对象之外。用户首次运行Chrome时,它们会应用到用户个人资料。完整的设置列表位于/ trunk / src / chrome / common /中的Chromium源文件pref_names.hpref_names.cc中。该列表相当长,因此此处仅显示一个子集。
{
// *************** PROFILE PREFS ***************
// These are attached to the user profile

// A string property indicating whether default apps should be installed
// in this profile.  Use the value "install" to enable defaults apps, or
// "noinstall" to disable them.  This property is usually set in the
// master_preferences and copied into the profile preferences on first run.
// Defaults apps are installed only when creating a new profile.
"default_apps"

// If set to true profiles are created in ephemeral mode and do not store their
// data in the profile folder on disk but only in memory.
"profile.ephemeral_mode"

// A boolean specifying whether the New Tab page is the home page or not.
"homepage_is_newtabpage"

// This is the URL of the page to load when opening new tabs.
"homepage"

// An integer pref. Holds one of several values:
// 0: (deprecated) open the homepage on startup.
// 1: restore the last session.
// 2: this was used to indicate a specific session should be restored. It is
//    no longer used, but saved to avoid conflict with old preferences.
// 3: unused, previously indicated the user wants to restore a saved session.
// 4: restore the URLs defined in kURLsToRestoreOnStartup.
// 5: open the New Tab Page on startup.
"session.restore_on_startup"

// The URLs to restore on startup or when the home button is pressed. The URLs
// are only restored on startup if kRestoreOnStartup is 4.
"session.startup_urls"

// Boolean that is true when SafeBrowsing is enabled.
"safebrowsing.enabled"

// Boolean that tell us whether malicious download feedback is enabled.
"safebrowsing.extended_reporting_enabled"

/* Might be useful for highly-secure workstations. */
// Enum that specifies whether Incognito mode is:
// 0 - Enabled. Default behaviour. Default mode is available on demand.
// 1 - Disabled. Used cannot browse pages in Incognito mode.
// 2 - Forced. All pages/sessions are forced into Incognito.
"incognito.mode_availability"

// Boolean that is true when Suggest support is enabled.
"search.suggest_enabled"

// A boolean pref set to true if a Home button to open the Home pages should be
// visible on the toolbar.
"browser.show_home_button"

// Boolean that indicates whether we should check if we are the default browser
// on start-up.
"browser.check_default_browser"

// Policy setting whether default browser check should be disabled and default
// browser registration should take place.
"browser.default_browser_setting_enabled"

// Boolean that specifies whether to import bookmarks from the default browser
// on first run.
"import_bookmarks"

// Boolean that specifies whether to import the browsing history from the
// default browser on first run.
"import_history"

// Boolean that specifies whether to import the homepage from the default
// browser on first run.
"import_home_page"

// Boolean that specifies whether to import the search engine from the default
// browser on first run.
"import_search_engine"

// Boolean that specifies whether to import the saved passwords from the default
// browser on first run.
"import_saved_passwords"

// Boolean that specifies if the sign in promo is allowed to show on first run.
// This preference is specified in the master preference file to suppress the
// sign in promo for some installations.
"sync_promo.show_on_first_run_allowed"

// *************** LOCAL STATE ***************
// These are attached to the machine/installation

// Note: Both settings included below are for Windows only.

// Whether downloaded PDFs should be opened in Adobe Acrobat Reader.
"download.open_pdf_in_adobe_reader"

// Preference to be used while relaunching Chrome. This preference dictates if
// Chrome should be launched in Metro or Desktop mode.
// For more info take a look at ChromeRelaunchMode enum.
"relaunch.mode"

// Boolean that specifies if the sign in promo is allowed to show on first run.
// This preference is specified in the master preference file to suppress the
// sign in promo for some installations.
"sync_promo.show_on_first_run_allowed";

// Boolean that specifies if we should show a bubble in the new tab page.
// The bubble is used to confirm that the user is signed into sync.
"sync_promo.show_ntp_bubble";

// As part of the master preferences an optional section indicates the tabs
// to open during first run. An example is the following:
"first_run_tabs": [
  "http://google.com/f1",
  "https://google.com/f2"
]
// Note that the entries are usually urls but they don't have to be.
  1. 选择所需的设置,然后编写自己的自定义master_preferences文本文件。这是Windows Installer文件中内置的文件(出于可读性考虑,扩展到多行):
{
  "distribution" : 
  {
    "msi" : true,
    "system_level" : true,
    "verbose_logging" : true
  }
}

您必须包含master_preferences文件中显示的所有这些属性,才能使安装程序正常工作。因此,您应该从此开始并添加到它。我的文件如下所示。我发现阻止Chrome要求用户配置Google帐户的唯一方法是设置first_run_tabs属性。

{
  "browser" : {
    "check_default_browser" : false
  },
  "distribution" : {
    "import_bookmarks" : false,
    "import_history" : false,
    "import_home_page" : false,
    "import_search_engine" : false,
    "suppress_first_run_bubble" : true,
    "do_not_create_desktop_shortcut" : true,
    "do_not_create_quick_launch_shortcut" : true,
    "do_not_create_taskbar_shortcut" : true,
    "do_not_launch_chrome" : true,
    "do_not_register_for_update_launch" : true,
    "make_chrome_default" : false,
    "make_chrome_default_for_user" : false,
    "msi" : true,
    "require_eula" : false,
    "suppress_first_run_default_browser_prompt" : true,
    "system_level" : true,
    "verbose_logging" : true
  },
  "first_run_tabs" : [
    "chrome://newtab"
  ],
  "homepage" : "chrome://newtab",
  "homepage_is_newtabpage" : true,
  "sync_promo" : {
    "show_on_first_run_allowed" : false
  }
}
  1. 浏览到http://jslint.com/,将JSON复制到Source框中,然后单击JSLint按钮。这将验证您具有良好的JSON。这很重要,因为向安装程序提供格式错误的JSON会产生意外和/或不良结果。保存已验证的文件,以备将来参考。

  2. 复制已验证的JSON,然后删除所有空格和换行。Chrome安装程序无法处理换行符;包括换行符将导致安装损坏,必须通过注册表操作和手动删除文件来删除安装。删除空格可能不是必需的,但它与设置作者使用默认JSON所做的操作匹配。我的如下图所示。

{"browser":{"check_default_browser":false},"distribution":{"import_bookmarks":false,"import_history":false,"import_home_page":false,"import_search_engine":false,"suppress_first_run_bubble":true,"do_not_create_desktop_shortcut":true,"do_not_create_quick_launch_shortcut":true,"do_not_create_taskbar_shortcut":true,"do_not_launch_chrome":true,"do_not_register_for_update_launch":true,"make_chrome_default":false,"make_chrome_default_for_user":false,"msi":true,"require_eula":false,"suppress_first_run_default_browser_prompt":true,"system_level":true,"verbose_logging":true},"first_run_tabs":["chrome://newtab"],"homepage":"chrome://newtab","homepage_is_newtabpage":true,"sync_promo":{"show_on_first_run_allowed":false}}
  1. 通过JSLint运行不带空格的新JSON,以确保您没有引入任何错误。

  2. 将没有空格或换行符的已验证JSON复制到URL编码器中。我使用了URL在线编码/解码。保存编码后的JSON,以供安装程序使用,以备将来参考。我的编码JSON如下所示。

%7B%22browser%22%3A%7B%22check_default_browser%22%3Afalse%7D%2C%22distribution%22%3A%7B%22import_bookmarks%22%3Afalse%2C%22import_history%22%3Afalse%2C%22import_home_page%22%3Afalse%2C%22import_search_engine%22%3Afalse%2C%22suppress_first_run_bubble%22%3Atrue%2C%22do_not_create_desktop_shortcut%22%3Atrue%2C%22do_not_create_quick_launch_shortcut%22%3Atrue%2C%22do_not_create_taskbar_shortcut%22%3Atrue%2C%22do_not_launch_chrome%22%3Atrue%2C%22do_not_register_for_update_launch%22%3Atrue%2C%22make_chrome_default%22%3Afalse%2C%22make_chrome_default_for_user%22%3Afalse%2C%22msi%22%3Atrue%2C%22require_eula%22%3Afalse%2C%22suppress_first_run_default_browser_prompt%22%3Atrue%2C%22system_level%22%3Atrue%2C%22verbose_logging%22%3Atrue%7D%2C%22first_run_tabs%22%3A%5B%22chrome%3A%2F%2Fnewtab%22%5D%2C%22homepage%22%3A%22chrome%3A%2F%2Fnewtab%22%2C%22homepage_is_newtabpage%22%3Atrue%2C%22sync_promo%22%3A%7B%22show_on_first_run_allowed%22%3Afalse%7D%7D

编写Windows Installer转换

  1. 启动Orca。
  2. 以只读方式打开下载的Chrome for Business MSI文件。(我想您可以编辑实际文件,但是我喜欢使用转换,因此如果出现问题,我总是将供应商提供的文件作为基准。)我下载了64位Chrome for Business 38,文件名为googlechromestandaloneenterprise64.msi
  3. 在“ 变换”菜单上,选择“ 新建变换”。现在,所有Windows Installer数据库表都是可编辑的,因为您正在编辑新的转换文件。
  4. 选择属性表。
  5. 右键单击“属性”列,然后单击“添加行”。将属性设置为MASTER_PREFERENCES,并将值设置为您的URL编码的JSON。此代码将在部署期间应用,master_preferences并由安装程序另存为安装文件。
  6. 选择CustomAction表,然后找到BuildInstallCommand操作。
  7. 双击BuildInstallCommand操作的“目标”单元以使其可编辑。
  8. 在文本末尾附近,删除现有的已编码JSON,installerdata=然后将其替换为方括号中的新属性名称。确保保留右引号。它看起来应该像这样: installerdata=[MASTER_PREFERENCES]"
  9. 按Enter键完成单元格的编辑。
  10. 在“ 转换”菜单上,单击“ 生成转换...”并保存新的MST文件。我把我的另存为E:\Chrome for Business 38 (64-bit)\MasterPreferences.mst
  11. 退出逆戟鲸。

注意:必须使用属性,而不是将JSON直接插入到自定义动作中,因为自定义动作的Target字段只有255个字符长。该表的架构无法更改,大多数自定义JSON将使该字段的总长度超过限制。使用属性避免了长度限制,因为对属性值的长度没有实际限制。

通过转换安装Chrome

  1. 使用管理权限打开命令提示符窗口。
  2. 通过将TRANSFORMS属性设置为文件名来安装Google Chrome浏览器。打开日志记录以帮助您发现任何错误。使用我的示例文件夹并假设您以管理员身份登录: msiexec /package "E:\Chrome for Business 38 (64-bit)\googlechromestandaloneenterprise64.msi" TRANSFORMS="E:\Chrome for Business 38 (64-bit)\MasterPreferences.mst" /l*v "C:\Users\Administrator\Desktop\ChromeInstallationLog.txt"
  3. 如果Chrome安装没有错误,请尝试以其他非管理员用户身份运行它,以确保设置正确传播。
  4. 最后,使用安装程序和转换文件配置部署系统。我使用System Center Configuration Manager 2012 R2。我为此应用程序创建的命令行类似于以下内容: msiexec /package "googlechromestandaloneenterprise64.msi" /quiet TRANSFORMS="MasterPreferences.mst" /l*v "%TEMP%\ChromeInstallationLog.txt" 这为我的用户提供了与Configuration Manager的软件中心应用程序类似的应用程序商店体验,将对桌面和任务栏图标的控制权留给了用户,并且避免了令人讨厌的首次运行体验。通常,这是我偏爱的用户体验,但是对于面向公众的计算机(例如在计算机实验室中,因为每次重新启动都会丢失硬盘驱动器更改,因此每次登录都是“首次”登录)尤其有用。

笔记

另请参阅master_preferences文件上的 Google 文档,该文件涵盖了可用设置的子集,但没有告诉您如何在安装过程中将设置获取到计算机上。

感谢grt@chromium.org指出了MSI自定义的可能性。我的目标是扩展该信息,以提供全面的解释和示例解决方案。希望对您有所帮助。


这是一个很好的指南。你是英雄。:-)
usershmusername

还是这样吗?谷歌的Soemone需要为此解雇。注册表应为“ it”-可能与指向文件名和位置的注册表项一样简单,可以在Wix中将其作为5分钟的琐碎工作推出。
TomTom,

0

我没有足够的代表来发表评论。我正在使用Jay的指南来帮助解决使下载的文件类型自动运行的问题。这似乎是目前唯一的方法:

https://bugs.chromium.org/p/chromium/issues/detail?id=476668

-此链接指向AFAIK未修复的错误。报告者希望能够设置特定的文件类型,以通过GPO在d / l上自动运行。考虑到安全隐患,此用例受到限制,但有时在企业部署中是必需的。可以在具有master_preferences的.mst中使用Jay的技术来实现。(根据小鸡的评论进行编辑)

我同意您Tomtom,应该有一个更简单的方法。大多数情况下,Google的.admx就足够了。


不管您有多少代表:仅链接的答案都可能会被删除。您是否可以将其作为答案本身有意义,而对于那些想验证您的意思或进行更深入研究的人,只需参考链接即可。 serverfault.com/help/how-to-answer
小鸡
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.