VBS Script to install fonts

The below little script will install fonts with a .ttf or.otf file extensions onto a computer. Simply place your font files into the same folder as where the script will be running from.

You could change strFontSourcePath to point to a specified location rather than grabbing the fonts from the same folder as the script.

I use this script as part of our computer build process to install a group of fonts.

Option Explicit
Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile

Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject")

strFontSourcePath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")

If objFSO.FolderExists(strFontSourcePath) Then

	Set objNameSpace = objShell.Namespace(strFontSourcePath)
	Set objFolder = objFSO.getFolder(strFontSourcePath)
	For Each objFile In objFolder.files
		If LCase(right(objFile,4)) = ".ttf" OR LCase(right(objFile,4)) = ".otf" Then
			If objFSO.FileExists(wshShell.SpecialFolders("Fonts") & objFile.Name) = False Then
				Set objFont = objNameSpace.ParseName(objFile.Name)
				Set objFont = Nothing
			End If
		End If
	'Wscript.Echo "Font Source Path does not exists"
End If

5 thoughts on “VBS Script to install fonts”

  1. This worked great, the only issue was the file exist wasn’t working.. just replace

    If objFSO.FileExists(wshShell.SpecialFolders(“Fonts”) & objFile.Name) = False Then


    If objFSO.FileExists(wshShell.SpecialFolders(“Fonts”) & “\” & objFile.Name) = False Then

    Then it worked perfect.. Thanks

    • FYI to anyone looking at this.

      The above user is correct, however if you copy and paste from the browser, the quotation marks are changed to some other type of quote. I had to just delete and replace the “” around the “Fonts” and the “\”

  2. Hi the scripts works great on machines that does not have the fonts. But if there is a font it prompts to hit YES/NO to replace the font. I am trying to deploy 18 fonts. I there any way to replace the existing font without prompting or just take automatically yes as an input.
    Thanks in advance


Leave a Reply to david C Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.