- 积分
- 110
- 最后登录
- 2021-2-28
- 精华
- 0
- 阅读权限
- 20
- 主题
- 67
- UID
- 43073
- 帖子
- 274
- PB币
- 1974
- 威望
- 0
- 贡献
- 0
- 技术
- 7
- 活跃
- 216
 
- UID
- 43073
- 帖子
- 274
- PB币
- 1974
- 贡献
- 0
- 技术
- 7
- 活跃
- 216
|
发表于 2021-2-26 18:11:14
|显示全部楼层
无人值守打开 BAT,添加一个示例*.BAT来引导。
*.bat >
echo.
echo 正在更改 Powershell 执行策略:不受限制
powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force"
powershell -File "instl.fonts.ps1"
instl.fonts.ps1
$Host.UI.RawUI.WindowTitle = "安装字体"
# 请设置要搜索的目录
$DirectoryStructure = @(
"Yi\Fonts"
"Fonts"
)
# 请设置搜索文件类型
$type = @(
"*.otf"
"*.ttf"
)
#region functions
function Install-Fonts {
param (
[string]$fontFile,
[string]$shortname
)
if ((Test-Path "$env:SystemDrive\Windows\fonts\$shortname") -or
(Test-Path "$env:LOCALAPPDATA\Microsoft\Windows\Fonts\$shortname")) {
Write-Host " '已安装' - $($fontFile)" -ForegroundColor Red
} else {
Write-Host " '安装中' - $($fontFile)" -ForegroundColor Green
(New-Object -ComObject Shell.Application).Namespace(0x14).CopyHere($_.FullName) | Out-Null
Write-Host " - 完成.`n" -ForegroundColor Green
}
}
#endregion
Write-host "`n 正在安装字体
---------------------------------------------------"
# install fonts
$drives = Get-PSDrive | Select-Object -ExpandProperty 'Name' | Select-String -Pattern '^[a-z]$'
foreach ($drive in $drives){
foreach ($nsf in $DirectoryStructure) {
Get-ChildItem "${drive}:\${nsf}" -Recurse -Include ($type) -ErrorAction SilentlyContinue | Foreach-Object {
Install-Fonts -fontFile $_.FullName -shortname $_.Name
}
}
} |
|