Last active
March 20, 2023 18:59
-
-
Save avoidik/d7217aa167fb3aadc36253f77232a7af to your computer and use it in GitHub Desktop.
install fonts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %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