很多时候都是直接装一大堆字体包
想同步字体到公司 导出又比较麻烦
想说动作能否来个一键导出到的功能
AI给的脚本,实测可用
$$<# .SYNOPSIS Windows字体备份脚本(管理员+用户字体) #> $备份路径 = "{导出路径}" $系统字体路径 = "C:\Windows\Fonts" $用户字体路径 = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts" # 创建备份目录 New-Item -ItemType Directory -Path "$备份路径\管理员权限字体" -Force | Out-Null New-Item -ItemType Directory -Path "$备份路径\当前用户字体" -Force | Out-Null # 1. 备份系统字体(带名称修正) $系统字体表 = @{} Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' | Get-Member -MemberType NoteProperty | Where-Object {$_.Name -notlike '*(*' -and $_.Name -ne 'PSPath'} | ForEach-Object { $显示名称 = $_.Name -replace ' \(.*\)$','' $文件名 = (Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' $_.Name) $系统字体表[$文件名] = $显示名称 } $系统字体文件 = Get-ChildItem $系统字体路径 $系统字体文件 | ForEach-Object { $目标名称 = if ($系统字体表.ContainsKey($_.Name)) { $系统字体表[$_.Name] + $_.Extension } else { $_.Name } Copy-Item $_.FullName "$备份路径\管理员权限字体\$目标名称" -Force } # 2. 备份用户字体(带名称修正) $用户字体文件 = if (Test-Path $用户字体路径) { Get-ChildItem $用户字体路径 } if ($用户字体文件) { $用户字体表 = @{} Get-ItemProperty 'HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -ErrorAction SilentlyContinue | Get-Member -MemberType NoteProperty | Where-Object {$_.Name -notlike '*(*' -and $_.Name -ne 'PSPath'} | ForEach-Object { $显示名称 = $_.Name -replace ' \(.*\)$','' $文件名 = (Get-ItemPropertyValue 'HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' $_.Name) $用户字体表[$文件名] = $显示名称 } $用户字体文件 | ForEach-Object { $目标名称 = if ($用户字体表.ContainsKey($_.Name)) { $用户字体表[$_.Name] + $_.Extension } else { $_.Name } Copy-Item $_.FullName "$备份路径\当前用户字体\$目标名称" -Force } } # 生成统计报告 $系统字体家族 = $系统字体表.Values | Sort-Object -Unique $用户字体家族 = if ($用户字体表) { $用户字体表.Values | Sort-Object -Unique } else { @() } $报告 = @" === 字体统计报告 === [管理员权限字体] 家族总数: $($系统字体家族.Count) 文件总数: $(($系统字体文件 | Measure-Object).Count) [当前用户字体] 家族总数: $($用户字体家族.Count) 文件总数: $(if ($用户字体文件) { ($用户字体文件 | Measure-Object).Count } else { 0 }) [存储信息] 备份时间: $(Get-Date) 存储路径: $备份路径 "@ $报告 | Out-File "$备份路径\字体统计报告.txt" Write-Host $报告 -ForegroundColor Cyan