Installing System Font with Powershell

carlbenson picture carlbenson · Apr 15, 2013 · Viewed 12.7k times · Source

I have a folder filled with TTF files of custom fonts. I need to install them as system fonts using a powershell script (this is on Windows Server 2008 R2). Does anybody know how to do that in powershell? Thanks!

Answer

gustavodidomenico picture gustavodidomenico · Apr 15, 2013

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