Last active
March 21, 2019 22:01
-
-
Save tushortz/cb22cc04171e983081ac7944cb8a9d3a to your computer and use it in GitHub Desktop.
This installs all the fonts placed in the "Desktop/fonts" directory of any windows pc
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
$FONTS = 0x14; | |
$CurrentWorkingDirectory = Get-Location; | |
Write-Output "Getting fonts from path: '$CurrentWorkingDirectory'"; | |
$ObjShell = New-Object -ComObject Shell.Application; | |
$ObjFolder = $ObjShell.Namespace($FONTS); | |
$CopyOptions = 4 + 16; | |
$CopyFlag = [String]::Format("{0:x}", $CopyOptions); | |
foreach($File in $(Get-ChildItem -Path $CurrentWorkingDirectory)){ | |
If ((Test-Path "c:\windows\fonts\$($File.name)") -eq $True) | |
{ | |
Write-Output "$($File.name) exists"; | |
} | |
Else | |
{ | |
$CopyFlag = [String]::Format("{0:x}", $CopyOptions); | |
$ObjFolder.CopyHere($File.fullname, $CopyOptions); | |
New-ItemProperty -Name $File.fullname -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $File; | |
} | |
} | |
Write-Output "Font installation complete"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use
environment variables
so it can be accessed from any location.install_windows_font.ps1