如何在 Windows 10 中自动将 Chrome 设置为默认浏览器

Jos*_*osh 29 browser windows-registry google-chrome command-line windows-10

我试过在 reg 键中设置默认值:

hkeycu>software>microsoft>windows>shell>associations>urlassociations>httphttps

尝试使用master_preference文件。

尝试使用命令 switch --make-default-browser

到目前为止,这些都不起作用。

任何帮助,将不胜感激。打开任何批处理文件、注册表项、文件替换/编辑...基本上任何我可以自动化的东西。

小智 11

您是否尝试制作.vbs文件以自动将 Chrome 设置为默认浏览器?

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome"
WScript.Sleep 1200
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WScript.Quit
Run Code Online (Sandbox Code Playgroud)

参考:用户“Raz”在 OSD 期间使 IE 成为 Windows 10 中的默认浏览器中的评论

  • 我注意到这使得 Chrome 成为它可以打开的所有文件类型的默认设置。这会覆盖在 Chrome 中打开 PDF 的默认设置,这在我的特定情况下不是首选。是否可以避免修改 PDF 文件类型?(.html、.shtml、.htm 等 - 除了 PDF 几乎所有内容)。我想我希望在“默认应用程序”(自动,最好是静默)中复制更改“Web 浏览器”的行为。 (2认同)
  • **不**在 Windows 10 `1809` 中工作 (2认同)
  • 此答案在 Windows 10 1803 中停止工作。相反,请使用[此答案](https://superuser.com/a/1397843)。 (2认同)

小智 9

要更改 Windows 10 中的默认浏览器,请尝试使用 Christoph Kolbicz 的工具 - https://kolbi.cz/blog/2017/11/10/setdefaultbrowser-set-the-default-browser-per-user-on-windows-10-和-server-2016-build-1607/

启动了SetDefaultBrowser.exe HKLM "Google Chrome",对我来说效果很好。


Ben*_*ert 7

Judy Li的答案在 2021-01-04 构建的最新 Windows 10 上仍然对我有用。但是,我必须更新选项卡和睡眠命令的数量。

更新后的步骤是:

  1. 使用以下代码创建 VBS 文件
  2. shell:startup使用 [win]+[r] 或文件资源管理器打开文件夹
  3. 将文件存储在启动文件夹中,以便每次重新启动时执行脚本

VBS代码

Set WshShell = WScript.CreateObject("WScript.Shell")

' Open the default settings window
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome"
WScript.Sleep 5000 ' Wait until open (adjust if necessary)

' Adjust number of tabs until you reach the browser choice setting
WshShell.SendKeys "{TAB}" 
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"

' Open the browser choice menu
WshShell.SendKeys " " 
WScript.Sleep 500 ' Wait until open

WshShell.SendKeys "{TAB}" ' Move down one selection
WshShell.SendKeys " " ' Set current selection as default browser

WScript.Sleep 500 ' Wait until open
' Uncomment the line below to outomatically close the settings window
' WshShell.SendKeys "%{F4}" 
WScript.Quit
Run Code Online (Sandbox Code Playgroud)


小智 6

以下是 Judy Li / Raz 解决方案的 PowerShell 版本:

function Set-ChromeAsDefaultBrowser {
    Add-Type -AssemblyName 'System.Windows.Forms'
    Start-Process $env:windir\system32\control.exe -ArgumentList '/name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome'
    Sleep 2
    [System.Windows.Forms.SendKeys]::SendWait("{TAB} {TAB}{TAB} ")
}
Run Code Online (Sandbox Code Playgroud)