Installing System Font with Powershell Installing System Font with Powershell powershell powershell

Installing System Font with Powershell


It is quite simple. Take a look on the snippet below:

$FONTS = 0x14$objShell = New-Object -ComObject Shell.Application$objFolder = $objShell.Namespace($FONTS)$objFolder.CopyHere("C:\test\Myfont.ttf")

And it should not require to restart/logoff...

The 0x14 value is the CLSID of the special folder.

In addition I just found this tutorial explaining each step above:

http://windowsitpro.com/scripting/trick-installing-fonts-vbscript-or-powershell-script


Just wanted to post an alternative which doesn't require 0x14 to be hard coded into the script. Pass the file object to the function, and it will just run the "Install" based on where the file is:

Function Install-Font {   Param (      [Parameter(Mandatory=$true,ValueFromPipeline=$true)][System.IO.FileSystemInfo[]]$File   )   $shell = New-Object -ComObject Shell.Application   $File | % {      $Fonts = $shell.NameSpace($_.Directory.Name)      $font = $Fonts.ParseName($_.Name)      $font.InvokeVerb("Install")   }}


Using the Shell.Application COM object doesn't work on Server Core (at least not on 2012 R2).

I had success by simply copying the font file to C:\Windows\Fonts (in this case times.ttf) and then adding the corresponding registry entry with PowerShell:

New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -Name 'Times New Roman (TrueType)' -PropertyType String -Value times.ttf

Removal is the reverse of installation. The only downside is that a restart is required both after the font has been installed and also before it is uninstalled if an application has referenced it.