Skip to content

Instantly share code, notes, and snippets.

@tushortz
Last active March 21, 2019 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tushortz/cb22cc04171e983081ac7944cb8a9d3a to your computer and use it in GitHub Desktop.
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
$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";
@tushortz
Copy link
Author

How to use

  1. Add the file location to the environment variables so it can be accessed from any location.
  2. Navigate to the location of the font from terminal and run install_windows_font.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment