Deploy Custom Fonts to Client Computers via Group Policy

You’ve been asked to deploy new set of custom fonts to all the computers in your network and you’ve tried many of the online solutions but non of them work. Please try this script and set it to run on the next computer startup using Group Policy.

1. This script will only work with OTF font format it will scan for .otf file extensions within given folder you could use this online convertor to convert your fonts from usually TTF font format to OTF or use another convertor of your choice.

2. Save the converted fonts into the new folder call it whatever you like and copy the new fonts folder to the shared location on your network make sure that this location can be accessed by all your client computers. Please test the location from a client computer before using it in our script below.

3. Open the notepad and paste the following code. Make sure you edit \\YOURSERVER\FONTSFOLDER path to reflect the path to your shared fonts folder then save the file with the name InstallCustomFonts and .vbs extension (InstallCustomFonts.vbs).

Dim strFontDir, exts, boolHasFonts
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Copy font files to the local machine
strFontDir = "\\YOUSERVER\FONTSFOLDER" ' remote directory containing fonts
boolHasFonts = False

' Setup filtering to grab only fonts
Set exts = CreateObject("Scripting.Dictionary")
exts.CompareMode = vbTextCompare  'case-insensitive
exts.Add "otf", True

' Make sure font directory exists before copying to machine
If objFSO.FolderExists(strFontDir) Then
  
  ' Go through each file in the specified font directory
  Dim objFontSrc, objFont, boolFontCopied
  Set objFontSrc = objFSO.GetFolder(strFontDir)
  boolFontCopied = False ' keeps track of if any fonts were actually installed
  
  For Each objFont In objFontSrc.Files
    
    ' If file is a font, copy it to the local machine
    If exts.Exists(objFSO.GetExtensionName(objFont.Name))  Then
          
      ' Copied with Shell.Application automatically installs fonts
      Dim objLocalFontFolder, strLocalFontFolder
      Set objLocalFontFolder = CreateObject("Shell.Application").Namespace(&H14&)
      Set strLocalFontFolder = objLocalFontFolder.Self
      strLocalFontFolder = strLocalFontFolder.Path & "\"
            
      ' Test to see if fonts are already installed
      If Not objFSO.FileExists(strLocalFontFolder & objFont.Name) Then
        objLocalFontFolder.CopyHere objFont.Path
        boolFontCopied = True
      End If
      
      boolHasFonts = True ' Keep track of if any fonts were found / copied
    End If
    
  Next
  
  ' Complain if no fonts were located in the remote directory
  If Not boolHasFonts Then
  Wscript.Echo "No fonts found in source directory."
  '  writeToLog("Error: No fonts found in remote directory!." & strFontDir)
  '  errors = errors + 1
  Else
    If boolFontCopied Then
      Wscript.Echo "Success.Fonts installed"
	  'writeToLog("Fonts installed.")
    Else 
    Wscript.Echo "Fonts already installed."
	'  writeToLog("All fonts already installed, installation skipped.")
    End If    
  End If    
  
Else
  Wscript.Echo "The Font destination directory is missing!"
  'writeToLog("Error: Missing Font Directory! " & strFontDir)
  errors = errors + 1
End If

4. Next step is to setup computer startup policy in Group Policy (Computer Configuration > Policies > Windows Settings > Scripts > Startup) and add our InstallCustomFonts.vbs script. If you are not sure how to do this please follow this tutorial.

5. Once we have our policy in place we need to wait for our polices to propagate to all of our client computers or we can run command prompt as administrators and force the update manually on our test machine using the command gpupdate /force then restart the computer and login to test it.

Once this new policy is in place all that is required is for users to login and use the newly deployed fonts.