Guest Posted October 31, 2006 Posted October 31, 2006 Don't know if this will be of use to anyone here, but have created a small VB startup Script that can be used to install new fonts. It just copies the files froma server and registers them. If anyone would like it ill post the code and instructions?
ChrisH Posted October 31, 2006 Posted October 31, 2006 Sounds good. You should always post your code as it is a good reference for other people with similar projects.
ITWombat Posted October 31, 2006 Posted October 31, 2006 Yes Sysman. Get your script out for the geeks
Guest Posted November 1, 2006 Posted November 1, 2006 Here goes - I hope this makes some sense. Create a Folder to house all your additional fonts on a network share e.g. \\%SERVERNAME%\%SHARE%\FONTS Copy the new font to that share e.g. Twiggy-Bold.ttf Install the new font onto a workstation. Using regedit browse to the following Key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts Make a note of the new fonts registry information. Add this new information to the VB script Create a new GPO and add the script to run at computer start up Assign to computers The font will be available after a restart of the PC with no need for an admin logon. To update the script quickly I just created a shortcut to the policy folder and then just copy the updated VB script when I have added new fonts. And here's the code ' **************************************************************************** ' Copy Fonts From Network Share To C:\WINDOWS\FONTS Folder Of Workstation ' **************************************************************************** Set WshShell = CreateObject("WScript.Shell") WshShell.Run "xcopy.exe ""\\%SERVERNAME%\%SHARE \FONTS"" ""C:\windows\fonts"" /C /I /S /E /H /Y /Q", 1,True ' **************************************************************************** ' Imports The Registry Information For The New Fonts - Add A New Line For Each New Font ' Example : WshShell. RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\%FONT REG KEY%", "%FONT REG KEY ENTRY%", "REG_SZ" ' **************************************************************************** Set WshShell = WScript.CreateObject("WScript.Shell") WshShell. RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\Twiggy-Bold (TrueType)", "Twiggy-Bold.ttf", "REG_SZ" WshShell. RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\Twiggy-Light (TrueType)", "Twiggy-Light.ttf", "REG_SZ"
contink Posted November 1, 2006 Posted November 1, 2006 Thanks for sharing... I suspect that's going to make life a lot easier
ChrisH Posted November 16, 2006 Posted November 16, 2006 Thought this might be good for some people on the same topic it shows you how to make an installer for custom fonts. http://www.ryanvm.net/forum/viewtopic.php?t=1401&sid=39d29df4ab382c604ad56886e79aa580 1
mcjohn87 Posted August 10, 2009 Posted August 10, 2009 Great work .. really informative .. and thanks a lot for sharing ..
mcjohn87 Posted August 10, 2009 Posted August 10, 2009 thanks so much for useful info:) script install
Popular Post srochford Posted August 10, 2009 Popular Post Posted August 10, 2009 Copying the fonts and writing the registry keys will work but sometimes seems to need a restart of Explorer (so if you run this at startup then the fonts will be there the next time the machine starts). The link from @chrish looks fine but it looks like hard work :-) MS provide scripting support for installing fonts - the code I've used is below. Basically, put any fonts you want installing in a server folder (\\server\share\fonts in the example) and then call this code as an extra sub-routine in your machine startup script. If you ever want to add a new font, just copy it to the server; next time the machines reboot they'll install it. Sub InstallFonts on error resume next Const FONTS = &H14 dim , oFSO,oShell, oFolder1, oFolder2, sRoot sRoot="\\server\share\fonts\" Set oShell = CreateObject("Shell.Application") set oFSO=createobject("scripting.filesystemobject") Set oFolder1 = oShell.Namespace(FONTS) set oFolder2=ofso.getfolder(sRoot) for each oFile in oFolder2.files sName=lcase(oFile.name) if right(sName,4)=".ttf" then if not ofso.fileexists(oFolder1.self.path & "\" & sName) then oFolder1.copyhere sRoot & sName end if end if next on error goto 0 End Sub 5
dhicks Posted August 10, 2009 Posted August 10, 2009 Basically, put any fonts you want installing in a server folder (\\server\share\fonts in the example) and then call this code as an extra sub-routine in your machine startup script. Darn, I thought simply copying fonts into C:\Windows\Fonts was enough. -- David Hicks 1
chrbb Posted March 15, 2011 Posted March 15, 2011 Copying the fonts and writing the registry keys will work but sometimes seems to need a restart of Explorer (so if you run this at startup then the fonts will be there the next time the machine starts). The link from @chrish looks fine but it looks like hard work :-) MS provide scripting support for installing fonts - the code I've used is below. Basically, put any fonts you want installing in a server folder (\\server\share\fonts in the example) and then call this code as an extra sub-routine in your machine startup script. If you ever want to add a new font, just copy it to the server; next time the machines reboot they'll install it. Sub InstallFonts on error resume next Const FONTS = &H14 dim , oFSO,oShell, oFolder1, oFolder2, sRoot sRoot="\\server\share\fonts\" Set oShell = CreateObject("Shell.Application") set oFSO=createobject("scripting.filesystemobject") Set oFolder1 = oShell.Namespace(FONTS) set oFolder2=ofso.getfolder(sRoot) for each oFile in oFolder2.files sName=lcase(oFile.name) if right(sName,4)=".ttf" then if not ofso.fileexists(oFolder1.self.path & "\" & sName) then oFolder1.copyhere sRoot & sName end if end if next on error goto 0 End Sub Tried this today - could I get it to work ? No! I created a new folder on the server called fonts, shared it, full control for everyone. Copied the script, changed the server path tested it and it worked. So copied the script to Group Policy (server 2008) computer's startup scripts, rebooted the machines and it doesn't work. I have other scripts that work in the same OU. Any ideas anyone?
srochford Posted March 15, 2011 Posted March 15, 2011 Add in some debugging: Sub InstallFonts on error resume next Const FONTS = &H14 dim , oFSO,oShell, oFolder1, oFolder2, sRoot sRoot="\\server\share\fonts\" Set oShell = CreateObject("Shell.Application") set oFSO=createobject("scripting.filesystemobject") set oLog=ofso.createtextfile("c:\windows\temp\fonts.log",true) Set oFolder1 = oShell.Namespace(FONTS) set oFolder2=ofso.getfolder(sRoot) for each oFile in oFolder2.files sName=lcase(oFile.name) oLog.writeLine "found: " & sName if right(sName,4)=".ttf" then if not ofso.fileexists(oFolder1.self.path & "\" & sName) then oLog.writeLine "installing: " & sName oFolder1.copyhere sRoot & sName end if end if next on error goto 0 oLog.close End Sub - add the "olog" lines and it should write a log file to c:\windows\temp\fonts.log with some info about what's happening. If that file doesn't get created then the script just isn't running. If it gets created and it appears to not find any fonts then your script isn't able to read the fonts directory (remember you must have "domain computers" with read access to get that to work)
chrbb Posted March 16, 2011 Posted March 16, 2011 Sorted thanks, added authenticated users to fonts folder!
maximator152 Posted August 11, 2011 Posted August 11, 2011 If you are looking for an easy way to intall fonts in windows 7 with a little script. you can find it for free on our page: Cheers
maximator152 Posted August 11, 2011 Posted August 11, 2011 sorry forgot the link: install font with command line or script in windows 7 1
zachariah Posted January 30, 2012 Posted January 30, 2012 Excellent script from maximator152 there - thanks! Also, here is a page with easy details to quickly make an msi for one or more fonts: laslow.net/2009/02/23/installing-a-font-via-gpo-server-20032008/ (you'll need to have a copy of WininstallerLE, which I think is still free) I've used that method with no problems so far. The only slight inconvenience is the machines need a restart after the msi has run before the font is visible to the user.
Yoa1202 Posted February 19, 2012 Posted February 19, 2012 Add in some debugging: Sub InstallFonts on error resume next Const FONTS = &H14 dim , oFSO,oShell, oFolder1, oFolder2, sRoot sRoot="\\server\share\fonts\" Set oShell = CreateObject("Shell.Application") set oFSO=createobject("scripting.filesystemobject") set oLog=ofso.createtextfile("c:\windows\temp\fonts.log",true) Set oFolder1 = oShell.Namespace(FONTS) set oFolder2=ofso.getfolder(sRoot) for each oFile in oFolder2.files sName=lcase(oFile.name) oLog.writeLine "found: " & sName if right(sName,4)=".ttf" then if not ofso.fileexists(oFolder1.self.path & "\" & sName) then oLog.writeLine "installing: " & sName oFolder1.copyhere sRoot & sName end if end if next on error goto 0 oLog.close End Sub - add the "olog" lines and it should write a log file to c:\windows\temp\fonts.log with some info about what's happening. If that file doesn't get created then the script just isn't running. If it gets created and it appears to not find any fonts then your script isn't able to read the fonts directory (remember you must have "domain computers" with read access to get that to work) This script didn't work for me, when I double click it present an error in line4. This is what I have in line 4 sRoot="c:\font\c39hrp24dhtt.ttf" just to my localdisk. And there's no font.log in windows\temp to see what's happening. any Ideas?
PiqueABoo Posted February 19, 2012 Posted February 19, 2012 (edited) I've used fontreg for this in the past, have just put it in some package folder alongside the font files and run: fontreg /copy Edited February 19, 2012 by PiqueABoo 2
quietriot1983 Posted July 9, 2013 Posted July 9, 2013 Copying the fonts and writing the registry keys will work but sometimes seems to need a restart of Explorer (so if you run this at startup then the fonts will be there the next time the machine starts). The link from @chrish looks fine but it looks like hard work :-) MS provide scripting support for installing fonts - the code I've used is below. Basically, put any fonts you want installing in a server folder (\\server\share\fonts in the example) and then call this code as an extra sub-routine in your machine startup script. If you ever want to add a new font, just copy it to the server; next time the machines reboot they'll install it. Sub InstallFonts on error resume next Const FONTS = &H14 dim , oFSO,oShell, oFolder1, oFolder2, sRoot sRoot="\\server\share\fonts\" Set oShell = CreateObject("Shell.Application") set oFSO=createobject("scripting.filesystemobject") Set oFolder1 = oShell.Namespace(FONTS) set oFolder2=ofso.getfolder(sRoot) for each oFile in oFolder2.files sName=lcase(oFile.name) if right(sName,4)=".ttf" then if not ofso.fileexists(oFolder1.self.path & "\" & sName) then oFolder1.copyhere sRoot & sName end if end if next on error goto 0 End Sub When I run this, I get an "Expected Identifier" error, any ideas?
plexer Posted July 9, 2013 Posted July 9, 2013 Wow good old info this thread was started in 2006. Ben
thesk8rjesus Posted July 12, 2013 Posted July 12, 2013 Here is the script that I wrote the other day. It looks in a server folder for font files and installs them. It also checks if the font is already installed and then skips over it if it is, and then adds into the event log that the font was installed. We use this as a package on SCCM and push it out when we approve new fonts. Const FONTS = &H14& 'defining variables Dim FSO, fontPath, objShell, objFolder, wshShell, winDir 'setting variables Set FSO = CreateObject( "Scripting.FileSystemObject" ) Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(FONTS) Set wshShell = WScript.CreateObject( "WScript.Shell" ) 'setting strings fontPath = "\\servername\Fonts\" 'Change this folder path to font folder winDir = wshShell.ExpandEnvironmentStrings( "%windir%" ) For Each font In FSO.GetFolder( fontPath ).Files If( FSO.FileExists( winDir & "\fonts\" & FSO.GetFileName( font ) ) ) Then 'do nothing Else 'checking if file is a font If inStr( LCase( FSO.GetFileName( font ) ), "ttf" ) Or _ inStr( LCase( FSO.GetFileName( font ) ), "otf" ) Or _ inStr( LCase( FSO.GetFileName( font ) ), "fon" ) Then 'Installing font objFolder.CopyHere fontPath & FSO.GetFileName( font ), &H14& 'Add event to event viewer wshShell.LogEvent 4, "The " & FSO.GetFileName( font ) & " font has been installed." End If End If Next 3
old_n07 Posted July 16, 2013 Posted July 16, 2013 We use PowerShell to install fonts, this is the code $path = "\.ttf" $sa = new-object -comobject shell.application $Fonts = $sa.NameSpace(0x14) $Fonts.copyhere($path) 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now