重置 IE 与 Explorer 的搜索引擎

前言

相关阅读:在 Windows 打开 Internet Explorer

在 Windows 10 与 Windows 11 中,即使 Microsoft 已经停用独立的 Internet Explorer 11 并重定向至 Microsoft Edge,系统底层的外壳程序(explorer.exe)在地址栏输入非路径关键词时,依然会调用遗留的 SearchScopes 注册表接口发起网页搜索

在简体中文版 Windows 镜像中,系统出厂预设了带有渠道推广标识的百度搜索(URL 包含 tn=80035161_2_dg)
如果仅通过注册表编辑器或常规脚本直接修改 SearchScopes,系统内置的 EUPP(End User Personalization Protection,终端用户个性化保护) 防篡改哈希校验机制会判定该配置失效,从而强制回滚到出厂预设的百度

使用 Windows PowerShell 脚本,可以使底层 FeatureControl 写入豁免配置关闭外壳进程的 EUPP 校验,并同步清洗 HKEY_CURRENT_USER 与 HKEY_LOCAL_MACHINE 下的所有残留项,实现彻底将资源管理器与 Internet Explorer 接口的默认搜索引擎重置为 Bing 或第三方搜索引擎

重置搜索引擎为 Bing

新建文本文档,重命名为 ResetIESearchScopesToBing.ps1,将以下 Windows PowerShell 脚本内容保存
(由 Google Gemini 3.8 Flash 修正)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Stop-Process -Name iexplore -Force -ErrorAction SilentlyContinue

$targetProcesses = @(
"cscript.exe",
"explorer.exe",
"iexplore.exe",
"mshta.exe",
"powershell.exe",
"pwsh.exe",
"wscript.exe"
)

$featurePaths = @(
"HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_EUPP_GLOBAL_FORCE_DISABLE",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_EUPP_GLOBAL_FORCE_DISABLE",
"HKCU:\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_EUPP_GLOBAL_FORCE_DISABLE"
)

foreach ($path in $featurePaths) {
if (-not (Test-Path $path)) { New-Item -Path $path -Force | Out-Null }
foreach ($proc in $targetProcesses) {
Set-ItemProperty -Path $path -Name $proc -Type DWord -Value 1
}
}

# 清理 EUPP 散列缓存
Remove-Item -Path "HKCU:\Software\Microsoft\Internet Explorer\EUPP" -Recurse -Force -ErrorAction SilentlyContinue

$bingGuid = "{0633EE93-D776-472f-A0FF-E1416B8B2E3A}"
$bingProps = @{
"DisplayName" = "Bing"
"FaviconURL" = "http://www.bing.com/favicon.ico"
"FaviconURLFallback" = "http://www.bing.com/favicon.ico"
"URL" = "http://www.bing.com/search?q={searchTerms}&src=IE-SearchBox&FORM=IESR02"
"SuggestionsURL" = "http://api.bing.com/qsml.aspx?query={searchTerms}&maxwidth={ie:maxWidth}&rowheight={ie:rowHeight}&sectionHeight={ie:sectionHeight}&FORM=IESS02&market={language}"
"SuggestionsURLFallback" = "http://api.bing.com/qsml.aspx?query={searchTerms}&maxwidth={ie:maxWidth}&rowheight={ie:rowHeight}&sectionHeight={ie:sectionHeight}&FORM=IESS02&market={language}"
"NTURL" = "http://www.bing.com/search?q={searchTerms}&src=IE-SearchBox&FORM=IENTSR"
"NTTopResultURL" = "http://www.bing.com/search?q={searchTerms}&src=IE-SearchBox&FORM=IENTTR"
"NTSuggestionsURL" = "http://api.bing.com/qsml.aspx?query={searchTerms}&market={language}&maxwidth={ie:maxWidth}&rowheight={ie:rowHeight}&sectionHeight={ie:sectionHeight}&FORM=IENTSS"
"NTLogoURL" = "http://go.microsoft.com/fwlink/?LinkID=403856&language={language}&scale={scalelevel}&contrast={contrast}"
"ShowSearchSuggestions" = 1
}

$scopesRoots = @(
"HKCU:\Software\Microsoft\Internet Explorer\SearchScopes",
"HKLM:\SOFTWARE\Microsoft\Internet Explorer\SearchScopes",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\SearchScopes"
)

foreach ($root in $scopesRoots) {
if (Test-Path $root) {
Set-ItemProperty -Path $root -Name "DefaultScope" -Value $bingGuid -ErrorAction SilentlyContinue

# 删除旧百度或推广项
Get-ChildItem -Path $root -ErrorAction SilentlyContinue | ForEach-Object {
$prop = Get-ItemProperty -Path $_.PsPath -ErrorAction SilentlyContinue
if ($prop.URL -like "*baidu.com*" -or $prop.URL -like "*80035161*" -or $_.PSChildName -eq "{64AF4D11-6492-4C25-B014-B6C6CEE3B0C5}") {
Remove-Item -Path $_.PsPath -Recurse -Force -ErrorAction SilentlyContinue
}
}

# 写入 Bing
$bingPath = Join-Path $root $bingGuid
if (-not (Test-Path $bingPath)) { New-Item -Path $bingPath -Force | Out-Null }
foreach ($key in $bingProps.Keys) {
$val = $bingProps[$key]
if ($val -is [int]) {
Set-ItemProperty -Path $bingPath -Name $key -Type DWord -Value $val -Force
} else {
Set-ItemProperty -Path $bingPath -Name $key -Type String -Value $val -Force
}
}
}
}

# 统一修正 SearchUrl 默认模板
$searchUrlPaths = @(
"HKCU:\Software\Microsoft\Internet Explorer\SearchUrl",
"HKLM:\SOFTWARE\Microsoft\Internet Explorer\SearchUrl",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\SearchUrl"
)
foreach ($path in $searchUrlPaths) {
if (-not (Test-Path $path)) { New-Item -Path $path -Force | Out-Null }
Set-ItemProperty -Path $path -Name "(Default)" -Value "http://www.bing.com/search?q=%s"
}

Stop-Process -Name explorer -Force

所有的操作都需要管理员身份,执行前请二选一执行以下操作:

  • 按下 WIN + X 以打开“高级菜单”,选择“终端管理员”,“Windows PowerShell (管理员)”或“命令提示符(管理员)”
  • 按下 WIN + Q 或 WIN + S 以打开“Windows 搜索”,输入 wt.exe(终端)、cmd.exe(命令提示符)或 powershell.exe(Windows PowerShell),选择最佳匹配结果并点击“以管理员身份运行”

如果运行的控制台不为 CMD(命令提示符),请输入 cmd.exe 以启动它

在以管理员身份运行的 CMD 中,执行这个脚本:

1
powershell.exe -ExecutionPolicy Bypass -File "文件路径"

例如,我将 ResetIESearchScopesToBing.ps1 保存到了 C 盘根目录,则命令如下:

1
powershell.exe -ExecutionPolicy Bypass -File "C:\ResetIESearchScopesToBing.ps1"

Windows PowerShell 下可以直接执行:
& “C:\ResetIESearchScopesToBing.ps1”
但是要手动打开 Windows 开发者模式

执行完成后,explorer.exe 会自动重启

如果使用其他搜索引擎

如果需要去除网站图标与搜索联想,仅需要保留 $bingProps 字段的 DisplayName、URL 与 ShowSearchSuggestions(该项设为 0)
以下为旧模板,将其中的内容替换为新模板内容即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$bingGuid = "{0633EE93-D776-472f-A0FF-E1416B8B2E3A}"
$bingProps = @{
"DisplayName" = "Bing"
"FaviconURL" = "http://www.bing.com/favicon.ico"
"FaviconURLFallback" = "http://www.bing.com/favicon.ico"
"URL" = "http://www.bing.com/search?q={searchTerms}&src=IE-SearchBox&FORM=IESR02"
"SuggestionsURL" = "http://api.bing.com/qsml.aspx?query={searchTerms}&maxwidth={ie:maxWidth}&rowheight={ie:rowHeight}&sectionHeight={ie:sectionHeight}&FORM=IESS02&market={language}"
"SuggestionsURLFallback" = "http://api.bing.com/qsml.aspx?query={searchTerms}&maxwidth={ie:maxWidth}&rowheight={ie:rowHeight}&sectionHeight={ie:sectionHeight}&FORM=IESS02&market={language}"
"NTURL" = "http://www.bing.com/search?q={searchTerms}&src=IE-SearchBox&FORM=IENTSR"
"NTTopResultURL" = "http://www.bing.com/search?q={searchTerms}&src=IE-SearchBox&FORM=IENTTR"
"NTSuggestionsURL" = "http://api.bing.com/qsml.aspx?query={searchTerms}&market={language}&maxwidth={ie:maxWidth}&rowheight={ie:rowHeight}&sectionHeight={ie:sectionHeight}&FORM=IENTSS"
"NTLogoURL" = "http://go.microsoft.com/fwlink/?LinkID=403856&language={language}&scale={scalelevel}&contrast={contrast}"
"ShowSearchSuggestions" = 1
}
1
Set-ItemProperty -Path $path -Name "(Default)" -Value "http://www.bing.com/search?q=%s"
  • DuckDuckGo:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $bingGuid = "{4B4A9E24-D4C8-4D46-9D6C-8684D3D7E951}"
    $bingProps = @{
    "DisplayName" = "DuckDuckGo"
    "FaviconURL" = "https://duckduckgo.com/favicon.ico"
    "FaviconURLFallback" = "https://duckduckgo.com/favicon.ico"
    "URL" = "https://duckduckgo.com/?q={searchTerms}"
    "SuggestionsURL" = "https://duckduckgo.com/ac/?q={searchTerms}&type=list"
    "SuggestionsURLFallback" = "https://duckduckgo.com/ac/?q={searchTerms}&type=list"
    "ShowSearchSuggestions" = 1
    }
    1
    Set-ItemProperty -Path $path -Name "(Default)" -Value "https://duckduckgo.com/?q=%s"
  • Google:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $bingGuid = "{B4B52382-774A-4847-B053-C8B99E26F225}"
    $bingProps = @{
    "DisplayName" = "Google"
    "FaviconURL" = "https://www.google.com/favicon.ico"
    "FaviconURLFallback" = "https://www.google.com/favicon.ico"
    "URL" = "https://www.google.com/search?q={searchTerms}"
    "SuggestionsURL" = "https://www.google.com/complete/search?output=toolbar&q={searchTerms}"
    "SuggestionsURLFallback" = "https://www.google.com/complete/search?output=toolbar&q={searchTerms}"
    "ShowSearchSuggestions" = 1
    }
    1
    Set-ItemProperty -Path $path -Name "(Default)" -Value "https://www.google.com/search?q=%s"
  • 其他:
    其他搜索引擎可以自己搜集一下他们的 GUID,或自定义
    可通过 PowerShell 命令以生成标准 GUID:[guid]::NewGuid().ToString("B").ToUpper()

    1
    2
    3
    4
    5
    6
    $bingGuid = "标准 GUID 值"
    $bingProps = @{
    "DisplayName" = "显示名称"
    "URL" = "https://example.com/search?q={searchTerms}" # 关键词必须为 {searchTerms}
    "ShowSearchSuggestions" = 0
    }
    1
    2
    # 关键词必须为 %s
    Set-ItemProperty -Path $path -Name "(Default)" -Value "https://example.com/search?q=%s"

后记

  1. URL 后缀中的 pc=EUPP_ 是什么
    在切换为 Bing 后,如果在资源管理器地址栏输入内容搜索,最终打开的链接可能会附带 &pc=EUPP_ 参数
    这是 Windows 外壳组件在调用 Bing 接口时原生组装的 Partner Code(渠道归因标识),代表流量来源于 Windows 外壳环境

  2. 为什么没有通过图形界面修改的方案
    在 Windows 10/11 弃用 Internet Explorer 之后,Windows 中绝大部分 Internet Explorer 相关的窗口被删除,“管理加载项”的窗口已经被移除“搜索提供程序”选项卡