批量添加edge的ie兼容模式网站
简介:
这几天在维修监控系统,150+摄像头,气的骂娘,视频参数调的太低,虽然录制时间长了,但是视频质量太低。
借着厂家工具进行了批量参数修改,结果osd也被批量修改了。还有定时重启参数,也要逐个web进去设置。
所以需要批量设置网段使用IE兼容模式。
于是就找到了这个解决方案。
一:兼容模式
以前只有微软独大的时候很多web应用使用了actions技术,浏览器装插件来实现功能,监控系统的摄像头就是使用这种技术来实现预览,配置摄像头参数的。
二:企业级兼容模式

原本在组策略中可以设置IE模式站点列表,大概位置是:
计算机配置 > 管理模板 > Microsoft Edge
但是我们调试监控系统的临时终端没有设置这些,就曲线救国,用注册表来直接实现
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge] "InternetExplorerIntegrationLevel"=dword:00000001 "InternetExplorerIntegrationSiteList"="C:\\IECompatSites.xml"
三:生成列表
随便一下就要生成一个网段来设置,还是写脚本生成配套的IECompatSites.xml文件吧。
windows也推powershell好多年了,确实比cmd优化了很多,就写powershell脚本吧。
四:完整脚本
1、灵活可调整
2、生成xml文件
3、添加注册表
# 脚本执行流程: # 生成XML文件 - 创建包含指定IP范围的IE兼容性站点列表 # 权限检查 - 验证是否具有管理员权限 # 注册表配置 - 自动配置Edge浏览器的IE集成设置 # 完成提示 - 显示配置结果和后续操作建议 # 使用方法: # 以管理员身份运行PowerShell # 执行脚本:.\IECompatSites.ps1 # 等待脚本完成所有配置 # 重启Edge浏览器 # 在Edge地址栏输入:edge://compat # 查看兼容性设置页面,确认配置是否生效 # # 组策略设置位置: # 1. 本地组策略编辑器:gpedit.msc # 2. 路径:计算机配置 > 管理模板 > Microsoft Edge # 3. 指定兼容性站点列表的路径或网址 # ======================================== # 配置变量 - 可根据需要修改 # ======================================== $ipFirstOctet = "192" # IP地址第一段 $ipSecondOctet = "168" # IP地址第二段 $ipThirdOctetStart = 0 # IP地址第三段起始值 $ipThirdOctetEnd = 10 # IP地址第三段结束值 $ipFourthOctetStart = 1 # IP地址第四段起始值 $ipFourthOctetEnd = 254 # IP地址第四段结束值 # 输出文件路径 $outputFile = "c:\IECompatSites.xml" # 注册表配置 $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" $ieIntegrationLevelValue = 1 $ieIntegrationSiteListValue = $outputFile # ======================================== # 脚本执行部分 # ======================================== Write-Host "开始生成IP地址范围 $ipFirstOctet.$ipSecondOctet.$ipThirdOctetStart.$ipFourthOctetStart 到 $ipFirstOctet.$ipSecondOctet.$ipThirdOctetEnd.$ipFourthOctetEnd..." -ForegroundColor Green # 开始构建XML内容字符串,避免PowerShell对象输出 $xmlContent = @" <?xml version="1.0" encoding="UTF-8"?> <site-list version="1"> "@ # 遍历IP地址范围 - 显示每个C段的进度 for ($thirdOctet = $ipThirdOctetStart; $thirdOctet -le $ipThirdOctetEnd; $thirdOctet++) { Write-Host "正在处理C段: $ipFirstOctet.$ipSecondOctet.$thirdOctet.*" -ForegroundColor Yellow for ($fourthOctet = $ipFourthOctetStart; $fourthOctet -le $ipFourthOctetEnd; $fourthOctet++) { $ipAddress = "$ipFirstOctet.$ipSecondOctet.$thirdOctet.$fourthOctet" $xmlContent += "`n <site url=`"$ipAddress`"><compat-mode>IE8Enterprise</compat-mode><open-in>IE11</open-in></site>" } } # 关闭XML标签 $xmlContent += "`n</site-list>" # 静默保存到文件 try { $xmlContent | Out-File -FilePath $outputFile -Encoding UTF8 -NoNewline Write-Host "成功生成IE兼容性站点文件: $outputFile" -ForegroundColor Green } catch { Write-Host "保存文件时出错: $($_.Exception.Message)" -ForegroundColor Red } # ======================================== # 注册表配置部分 # ======================================== Write-Host "`n正在配置Edge注册表设置..." -ForegroundColor Cyan # 检查是否以管理员权限运行 if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "警告: 此脚本需要管理员权限才能修改注册表设置。" -ForegroundColor Yellow Write-Host "请以管理员身份运行PowerShell来完成注册表配置。" -ForegroundColor Yellow exit 1 } try { # 创建注册表路径(如果不存在) if (!(Test-Path $registryPath)) { New-Item -Path $registryPath -Force | Out-Null Write-Host "已创建注册表路径: $registryPath" -ForegroundColor Green } # 设置IE集成级别 Set-ItemProperty -Path $registryPath -Name "InternetExplorerIntegrationLevel" -Value $ieIntegrationLevelValue -Type DWord Write-Host "已设置InternetExplorerIntegrationLevel为: $ieIntegrationLevelValue" -ForegroundColor Green # 设置IE集成站点列表路径 Set-ItemProperty -Path $registryPath -Name "InternetExplorerIntegrationSiteList" -Value $ieIntegrationSiteListValue -Type String Write-Host "已设置InternetExplorerIntegrationSiteList为: $ieIntegrationSiteListValue" -ForegroundColor Green Write-Host "注册表配置成功完成!" -ForegroundColor Green Write-Host "`n注意: 您可能需要重启Edge浏览器才能使更改生效。" -ForegroundColor Yellow } catch { Write-Host "配置注册表时出错: $($_.Exception.Message)" -ForegroundColor Red Write-Host "请确保您以管理员身份运行。" -ForegroundColor Red } Write-Host "`n脚本执行完成!" -ForegroundColor Green Write-Host "请在Edge浏览器地址栏输入以下命令查看兼容性设置:" -ForegroundColor Cyan Write-Host "edge://compat" -ForegroundColor Yellow

浙公网安备 33010602011771号