|
本帖最后由 2013kyj 于 2025-9-16 07:49 编辑
怎样用注册表批处理命令关闭下图中的两个选项
下面是deepseek的答案,设置后无效
- # 定义注册表路径和值的变量
- $edgeStartupBoostPath = "HKCU:\Software\Microsoft\Edge\StartupBoost"
- $edgeMainPath = "HKCU:\Software\Microsoft\Edge\Main"
- # 函数:确保注册表路径存在
- function Ensure-RegistryPath {
- param (
- [string]$path
- )
- if (-not (Test-Path $path)) {
- Write-Host "注册表路径不存在,正在创建: $path" -ForegroundColor Cyan
- New-Item -Path $path -Force | Out-Null
- }
- }
- try {
- # 确保 StartupBoost 路径存在
- Ensure-RegistryPath -path $edgeStartupBoostPath
- # 关闭 "启动增强" (Startup Boost)
- Set-ItemProperty -Path $edgeStartupBoostPath -Name "Enabled" -Value 0 -Type DWord -Force
- Write-Host "✅ 成功关闭 '启动增强'。" -ForegroundColor Green
- # 确保 Main 路径存在
- Ensure-RegistryPath -path $edgeMainPath
- # 关闭 "在后台运行 Microsoft Edge" (Continue running background apps...)
- Set-ItemProperty -Path $edgeMainPath -Name "ContinueRunningBackgroundAppsAfterBrowserCloses" -Value 0 -Type DWord -Force
- Write-Host "✅ 成功关闭 '在后台运行 Microsoft Edge'。" -ForegroundColor Green
- }
- catch {
- Write-Host "❌ 操作失败!错误信息:" -ForegroundColor Red
- Write-Host $_ -ForegroundColor Red
- }
- Write-Host "-------------------------------------" -ForegroundColor Gray
- Write-Host "所有操作已完成。请重新启动 Microsoft Edge 以使更改生效。" -ForegroundColor Yellow
- Read-Host "按 Enter 键退出"
复制代码
|
|