如果你的头像变成了:
找啊找,找到最后目录是:C:\Users\Public\AccountPictures\{sid}
我没有权限操作,说明是Windows更新篡改了默认头像。愚蠢的微软使用了一样的小尺寸图片作为不同尺寸的头像图,直接缩放的。因此这么地丑陋。
与gpt的聊天记录:https://chatgpt.com/share/68371fa3-7358-8008-a21f-a7f811a26219
通过与GPT的聊天,我写了个Powershell脚本来替换会win10默认的(从默认头像目录里获取)。
但是在使用之前,你需要修改目标目录的安全权限。修改成像这样的:
然后保存以下代码为replace2.ps1(或者别的名字)或者直接运行:
# 1. 获取当前用户 SID
$SID = ([System.Security.Principal.WindowsIdentity]::GetCurrent()).User.Value
$targetDir = "C:\Users\Public\AccountPictures\$SID"
$sourceDir = "C:\ProgramData\Microsoft\User Account Pictures"
Write-Output "targetDir = $targetDir"
Write-Output "sourceDir = $sourceDir"
# 可选资源列表(按优先级从高到低)
$sourceMap = @{
192 = "user-192.png"
32 = "user-32.png"
40 = "user-40.png"
48 = "user-48.png"
}
# 回退源头像
$defaultPng = Join-Path $sourceDir "user.png"
$defaultBmp = Join-Path $sourceDir "user.bmp"
# 遍历所有 *-Image*.jpg 文件
Get-ChildItem -Path $targetDir -Filter "*-Image*.jpg" -Force | ForEach-Object {
$file = $_
$match = $file.Name -match "-Image(\d+)\.jpg"
if ($match) {
$size = [int]$matches[1]
$targetPath = $file.FullName
# 选择最匹配的源图像
$sourceFile = $null
if ($sourceMap.ContainsKey($size)) {
$candidate = Join-Path $sourceDir $sourceMap[$size]
if (Test-Path $candidate) {
$sourceFile = $candidate
}
}
# 若无精确匹配,尝试 user.png
if (-not $sourceFile -and (Test-Path $defaultPng)) {
$sourceFile = $defaultPng
}
# 若还无,用 bmp
if (-not $sourceFile -and (Test-Path $defaultBmp)) {
$sourceFile = $defaultBmp
}
if ($sourceFile) {
try {
# 移除 S/H/R 属性
attrib -S -H -R $targetPath
Copy-Item -Path $sourceFile -Destination $targetPath -Force
# 恢复 S/H/R 属性
attrib +S +H +R $targetPath
Write-Host "✅ 替换 $($file.Name) ← $([System.IO.Path]::GetFileName($sourceFile))"
} catch {
Write-Host "❌ 替换失败:$($file.Name) - $($_.Exception.Message)" -ForegroundColor Red
}
} else {
Write-Host "❌ 未找到可用于替换的头像图像($($file.Name))"
}
} else {
Write-Host "❓ 文件名格式无效:$($file.Name)"
}
}
看到如下结果则一切顺利:
注销当前登录的账户,重新登录进来就生效了:
题外话,微软又在Windows上打广告了,烦啊:
除了这个之外,有时候的消息是让你登录微软账户。