Last active
August 5, 2019 11:37
-
-
Save ddieppa/c2bea8dccf6c4ce6cd9e33dac021efb3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Source for this script: https://www.mondaiji.com/blog/other/it/10247-windows-install-fonts-via-command-line | |
# create temp directory | |
$tempPath = "C:\InstallFont" | |
# Obtain system font folder for extraction | |
$fonts = 0x14 | |
$shell = New-Object -ComObject Shell.Application | |
$SystemFontsFolder = $shell.Namespace($fonts) | |
$FontFiles = Get-ChildItem -Path tempPath -Recurse -File -Include '*.ttf', '*.otf' | |
$SystemFontsPath = $SystemFontsFolder.Self.Path | |
foreach ($FontFile in $FontFiles) { | |
# $FontFile will be copied to this path: | |
$targetPath = Join-Path $SystemFontsPath $FontFile.Name | |
# So, see if target exists... | |
if (Test-Path $targetPath) { | |
# font file with the same name already there. | |
# delete and replace. | |
Remove-Item $targetPath -Force | |
Copy-Item $FontFile.FullName $targetPath -Force | |
} | |
else { | |
#install the font. | |
$SystemFontsFolder.CopyHere($FontFile.fullname) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment