This script, designed to run on an XP client, copies font files from a common namespace share and publishes them on the local machine. I had a bit of trouble finding a way to publish fonts using VBScript, so I resorted to rather brute-force methods. The script works for every valid system font format (at least all that I could test), but may not always populate the office font cache. Steps are: Copy new fonts; create registry entries; clear OS font cache. May require reboot.
getnetfonts.wsf
<job>
<script language="VBScript">'******************************************************************************'* Font Publisher'* Modified: 5:34 PM 1/27/2007 -JC Bilinski'******************************************************************************'On Error Resume NextstrComputer = "."Const HKEY_LOCAL_MACHINE = &H80000002Const OverwriteExisting = TRUE
NewFonts = FALSE'***create objects for later use ***Set WshShell = CreateObject( "WScript.Shell" )
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
'*** Dest Registry Path for Fonts *** strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"'*** Dest Path for Font files ***strSysPath = WshShell.ExpandEnvironmentStrings("%SystemRoot%")strFontDestPath = strSysPath & "\Fonts"'*** Font Type ***strFontType = "TrueType"'*** Source Path to Compare and Copy ***strFontSrcPath = "\\domain.tld\NameSpace\FontDistro\"'*** Copy source to destination ***Set objSrcFolder = objFSO.GetFolder(strFontSrcPath)Set colSrcFiles = objSrcFolder.FilesFor Each objSrcFile in colSrcFiles
strFontDestName = strFontDestPath & "\" & objSrcFile.NameIf Not (objFSO.FileExists(strFontDestName)) Then
strFontDispName = Split(objSrcFile.Name,".")(0) & " ( " & strFontType & ")"
objFSO.CopyFile objSrcFile.Path, strFontDestName, OverwriteExisting
objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strFontDispName, objSrcFile.Name
NewFonts = TRUEEnd If
Next'*** Delete Font Cache if needed ***If (NewFonts) Then
strFontcache = strSysPath & "\System32\FNTCACHE.DAT" objFSO.DeleteFile strFontcache, TRUEEnd If
Wscript.Quit
</script>
</job>

