原因找到
我给你的 UserPreferencesMask 第 3 个字节写错了------把它从 0x03 改成了 0x01,正好把"显示桌面背景图像"那个 bit (0x02) 关掉了。所以 explorer 重启那一瞬间是按新设置画的(黑底),蓝色那张是切换瞬间还没生效时残留的画面。
一键修正(关键 bit 加回去)
powershell
# 把 UserPreferencesMask 第 3 字节的 0x02 位("显示桌面背景图像")打开
$mask = (Get-ItemProperty 'HKCU:\Control Panel\Desktop').UserPreferencesMask
$mask[2] = $mask[2] -bor 0x02
Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name UserPreferencesMask -Value $mask -Type Binary
# 顺手用微软"性能优先 + 保留壁纸"的官方推荐组合,覆盖一遍更稳
$preset = [byte[]](0x90, 0x12, 0x03, 0x80, 0x10, 0x00, 0x00, 0x00)
Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name UserPreferencesMask -Value $preset -Type Binary
# 强刷壁纸 + 重启 explorer
$img = (Get-ItemProperty 'HKCU:\Control Panel\Desktop').Wallpaper
Add-Type @"
using System.Runtime.InteropServices;
public class W { [DllImport("user32.dll")] public static extern int SystemParametersInfo(int u,int i,string p,int f); }
"@ -ErrorAction SilentlyContinue
[void][W]::SystemParametersInfo(0x14, 0, $img, 0x03)
Stop-Process -Name explorer -Force
Start-Process explorer
"修正完成,当前壁纸: $img"
跑完桌面应该稳定显示 img0.jpg,且不会再被 Spotlight 覆盖(上一轮已把 SubscribedContent-338387Enabled=0 关掉了)。
如果还是黑
那就跳出"自定义性能"这条路,直接走最简单可靠的:
powershell
# 切到"调整为最佳外观",100% 显示壁纸
Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects' `
-Name VisualFXSetting -Value 1
Stop-Process -Name explorer -Force
Start-Process explorer
然后在 Win+R → SystemPropertiesPerformance 里手动 只取消勾选你不想要的几项动画(保留"显示桌面背景图像"勾上),这样 GUI 帮你写正确的 mask,比手算 bit 稳。

选 Custom,然后只勾 3 项
☑ Smooth edges of screen fonts 字体不勾就糊
☑ Show thumbnails instead of icons 文件夹里看图必备
☑ Show window contents while dragging 拖窗口体验差别极大
其余全部不勾 → Apply → OK。这套组合是性能/体验比最高的,跟"最佳性能"几乎没有 FPS 差距,但能保留可读性。
注意:Win11 这个对话框里已经没有"Show desktop background"那一项了 ------壁纸不再受这里控制。所以你之前选 "Adjust for best performance" 后变黑,不是这个对话框造成的 ,而是上一轮脚本里
UserPreferencesMask被我写歪了。
但壁纸还是黑
按上面 OK 之后,必须再跑一次"恢复 mask + 强刷壁纸",否则黑底不会自动回来:
powershell
# 用 Win11 默认 mask(带壁纸 bit)覆盖
$preset = [byte[]](0x9E, 0x1E, 0x07, 0x80, 0x12, 0x00, 0x00, 0x00)
Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name UserPreferencesMask -Value $preset -Type Binary
$img = (Get-ItemProperty 'HKCU:\Control Panel\Desktop').Wallpaper
Add-Type @"
using System.Runtime.InteropServices;
public class W { [DllImport("user32.dll")] public static extern int SystemParametersInfo(int u,int i,string p,int f); }
"@ -ErrorAction SilentlyContinue
[void][W]::SystemParametersInfo(0x14, 0, $img, 0x03)
Stop-Process -Name explorer -Force
Start-Process explorer
如果还是黑
最后保底------走 GUI,最稳:
Win+R → ms-settings:personalization-background →
"个性化你的背景" 选 "图片" → 浏览照片 → 选一张本地 jpg
GUI 设置会把 mask、Wallpaper、TranscodedWallpaper 一次性全写对,比脚本可靠。

还是黑色的


直接走 GUI 最稳,3 步搞定
脚本反复修 mask 不靠谱,咱们直接用系统设置------它会一次性把所有相关项写对。
步骤 1:选一张本地图(强烈建议先复制到自己文件夹)
powershell
# 把 Windows 自带的图复制到你 Pictures,避免权限/路径锁
Copy-Item "C:\Windows\Web\Wallpaper\Windows\img0.jpg" "$env:USERPROFILE\Pictures\my_wp.jpg" -Force
explorer "$env:USERPROFILE\Pictures"
步骤 2:打开"背景"设置
powershell
Start-Process "ms-settings:personalization-background"
界面里:
- 个性化你的背景 → 选 "图片"(不要选 Windows 聚焦/幻灯片)
- 点 "浏览照片" → 选刚才复制的
Pictures\my_wp.jpg - "为你的桌面图像选择一种调整方式" → 填充
步骤 3:如果背景区域是灰的、改不了
那就是注册表里有锁定项------跑这段彻底解锁:
powershell
# 删掉所有可能锁定壁纸的策略键
Remove-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'Wallpaper' -ErrorAction SilentlyContinue
Remove-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'WallpaperStyle' -ErrorAction SilentlyContinue
Remove-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'NoChangingWallpaper' -ErrorAction SilentlyContinue
Remove-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop' -Name 'NoChangingWallpaper' -ErrorAction SilentlyContinue
# 强制启用桌面合成(DWM 没运行也会黑)
Get-Service uxsms,Themes | Where-Object Status -ne 'Running' | Start-Service
# 把 mask 设成 Win11 出厂默认值
$preset = [byte[]](0x9E, 0x3E, 0x07, 0x80, 0x12, 0x00, 0x00, 0x00)
Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name UserPreferencesMask -Value $preset -Type Binary
跑完再去步骤 2 选图。
如果上面还是黑
请把这两条输出贴给我,能直接定位:
powershell
# 1) DWM/主题服务在不在跑
Get-Service uxsms, Themes, Themes | Format-Table Name, Status
# 2) 当前主题文件 + 是否高对比度
Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes' | Select CurrentTheme
Get-ItemProperty 'HKCU:\Control Panel\Accessibility\HighContrast' | Select Flags
如果 Flags 不是 126 之类的小数字而是含 1(开启),那就是高对比度模式被打开了------这个开关也会让桌面变纯黑。关闭办法:Win+左Alt+PrintScreen 切换,或 设置 → 辅助功能 → 对比度主题 → 选 "无"。
元凶
- 腾讯的桌面整理软件
- 不过确实清爽很多,可以专注工作了。
- 重新安装,背景就不是黑色了。
