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!
http://blogs.technet.com/b/heyscriptingguy/archive/2004/11/11/can-i-pin-a-file-to-the-start-menu-by-using-a-script.aspx

Comments (6)

  1. RichardSpitz says:

    Werner, unfortunately this method (InvokeVerb) doesn't provide us with a way to override/suppress the resulting prompt if the font is already installed.

  2. kassman says:

    Is there a way to tell it to override existing fonts or suppress the prompt to override an installed font?

  3. kassman says:

    Ok thanks we ended up using a packaging software

  4. Dan_IT says:

    Just add an if exist statement in front of it. If it exists, goto exit and skip over the install step.

  5. John says:

    Can u show some snippets for checking the if exist condition for objFolderItem.InvokeVerb("Install")

  6. how to remove font ? i tried invokeverbs("Delete") and it doesn't work even folderitem return null

Skip to main content