How to install a font from the command line on Windows 7

With the new Rupee symbol out, we’ve been getting a lot of queries about how to deploy a new font to Microsoft’s latest client OS, Windows 7. If there are a handful of computers you want to install the font on, here’s what you do:

  1. Walk over to the computer and log in as administrator.
  2. Copy the font file (.ttf) to the C:\Windows\Fonts folder using Windows Explorer.

But what if you’ve got 300 computers, or 500, or maybe even 10,000? That’s a whole lot of walking!

Why, you ask, can’t you just copy the font file into C:\Windows\Fonts via a batch file? That’s because the C:\Windows\Fonts is a special folder, but only when you access it with Windows Explorer. If you copy the font file to C:\Windows\Fonts using a batch file, the font file will be copied to the C:\Windows\Fonts folder, but will not be installed. When you use Windows Explorer to copy the font file to C:\Windows\Fonts, under the wraps, Windows Explorer determines that this is a special folder and looks up the special task associated with the copy operation. This happens to be “Install”, so even though you’ve done a copy-paste, what’s actually happening is that the font file is being installed. You will see a “Installing…” pop-up when you paste the font file in this folder.

Great, I hear you say, but you’re still not going to walk that much. Luckily, there’s no need to, thanks to the following VB script:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(" <Folder or Share Location> ")
Set objFolderItem = objFolder.ParseName(" <TTF File Name> ")
objFolderItem.InvokeVerb("Install")

Example:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("\\192.168.1.1\Font")
Set objFolderItem = objFolder.ParseName("rupi_foradian.ttf")
objFolderItem.InvokeVerb("Install")

The script creates an instance of the Shell.Application object, sets the namespace of the instance to the folder containing the font file, selects the font file and then "invokes" the Install action associated with the font file (the list of actions are available in the context menu - right-click - of the file when accessed using Windows Explorer). 

All that's left to do is now is deploy this script in the context an account that has both access to the share containing the font file and has administrator level access to the computer the font is to be installed on. One way in which this can be achieved is using Microsoft System Center Configuration Manager.

The script in my post is based on the one in the link below. Thanks Scripting Guy!
https://blogs.technet.com/b/heyscriptingguy/archive/2004/11/11/can-i-pin-a-file-to-the-start-menu-by-using-a-script.aspx