Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing System Font with Powershell

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!

like image 537
carlbenson Avatar asked Apr 15 '13 19:04

carlbenson


People also ask

How do I add a font to Windows PowerShell?

Run regedit.exe and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont. Right-click in the panel on the right side and create a new string value. Name that value “0″ or “00″ or however many zeros you need to create a new key.

Can Windows install OTF font?

What to Know. To install a font from a folder, open the folder containing the font, but do not open the font file. Next, open Control Panel, double-click Fonts, then drag the font file into the Fonts folder. To install a font directly from the font file, right-click or double-click the font file and select Install.


1 Answers

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

like image 96
gustavodidomenico Avatar answered Sep 20 '22 15:09

gustavodidomenico