Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to Install Fonts

Status
Not open for further replies.

rickism21

IS-IT--Management
Oct 10, 2013
17
0
0
US
Hello,

I have a vb scripts that will install a font when I push it through a GPO. It works however, it doesn't check to see if the font already installed. I added additional code I found online to check if the font already exists but it is not working. Can someone take a look? Thanks,



Const FONTS = &H14&

Set objShell = CreateObject("Shell.Application")

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objShell.Namespace(FONTS)

If objFSO.FileExists("C:\Windows\Fonts\3of9.TTF") Then

Wscript.Quit

Else

objFolder.CopyHere "\\abc.xxx.com\NETLOGON\3of9.TTF"

End If
 
what's not working? It may be your other script that isn't working.

use msgboxs to verify your new code works how you expect
Code:
If objFSO.FileExists("C:\Windows\Fonts\3of9.TTF") Then
   msgbox "the file exists"
else
   msgbox "the file does not exist"
end if

-Geates

PS. I think there's a registry key that needs to be set before the font shows up in the list. Here is the method that I used in the past to install a font.
Code:
CONST HKLM = &H80000002 
set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") 
objReg.SetStringValue HKLM, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", strName, strSourceFileName

 
I think my IF statement want not working. I will use your message code now and see if I get a response.
 
So your I got a message "the file exist" so that means it is there but not showing up when I go to view fonts in the C:/windows/fonts, it is listed there. What should I do next show it is visable?

Thanks for your help
 
Can I just add your code for the registry into the font script?

Thanks
 
define what is red. You have to have rights to modify the registry.
Code:
CONST HKLM = &H80000002 
strComputer = "."
[COLOR=#CC0000]strName = "Friendly font name"
strSourceFileName = "local (C:\) or UNC (\\server\share\) path to file"
[/color]set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") 
objReg.SetStringValue HKLM, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", strName, strSourceFileName

-Geates

 
I created a second script for the registry entry to be safe and it seems to all work now. Thanks my good man....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top