Skip to content

Instantly share code, notes, and snippets.

@avoidik
Last active March 20, 2023 18:59
Show Gist options
  • Save avoidik/d7217aa167fb3aadc36253f77232a7af to your computer and use it in GitHub Desktop.
Save avoidik/d7217aa167fb3aadc36253f77232a7af to your computer and use it in GitHub Desktop.
install fonts
# %localappdata%\Microsoft\Windows\Fonts
$FontFolder = "C:\Users\Gato\Downloads\Meslo-Win"
$FontItem = Get-Item -Path $FontFolder
$FontList = Get-ChildItem -Path "$FontItem\*" -Include ('*.fon','*.otf','*.ttc','*.ttf')
$FontRegistry = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
$Destination = Join-Path -Path (New-Object -ComObject Shell.Application).Namespace(0x1c).Self.Path -ChildPath "Microsoft\Windows\Fonts"
If (-Not (Test-Path $FontRegistry)) {
New-Item -Path $FontRegistry -Force | Out-Null
}
If (-Not (Test-Path $Destination -PathType Container)) {
New-Item -Path $Destination -ItemType Directory -Force | Out-Null
}
foreach ($Font in $FontList) {
Write-Host 'Installing font -' $Font.FullName
Copy-Item -Path $Font.FullName -Destination $Destination
$NewPath = Join-Path -Path $Destination -ChildPath $Font.name
Write-Host 'Writing font info to registry -' $Font.BaseName
New-ItemProperty -Name $Font.BaseName -Path $FontRegistry -PropertyType string -Value $NewPath -Force | Out-Null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment