Bohack

Check In and Tune Out!
 
 
« How To Fix GoogleTV and Netflix Problem of We’re unable to connect you to Netflix

Installing Fonts On Windows 7 From A VBScript

Print This Post Print This Post

Recently I needed to install a number of fonts from a folder into a Windows 7 installation. One notable change with fonts since Windows XP is that you can’t just copy the fonts to the fonts folder. Windows Vista and 7 needs to register the font in the registry.

This is automatically done by right clicking on the font to install and selecting install. However that is a mindless task if you need to do that on more than one computer. If you do choose to do it manually there is also room for human error. So I looked around for a vbscript to install a simple font and found one from Microsoft’s scripting guys. However it only installed one font and I needed to install a whole folder of fonts.

I decided to couple the vbscript with File System Objects to retrieve a directory listing of a specified folder. Then the script for loops thru the collection, as it loops it checks to see if you have the file already. If you don’t have the file it installs it into Windows using the proper install action.

If you decide to make this a startup script, remember that startup scripts are run under the local system security context and won’t be able to connect to remote servers. If you make this a login script the user will need rights to install the fonts. See this article if you choose the login script route: http://www.bohack.com/2011/04/allowing-non-administrators-to-install-fonts-in-windows-7/

Dim strFolder, itmFile
Dim objFSO, objFSOFolder, ObjFiles
Dim objShell, ObjFolder, ObjFolderItem

strfolder = "\\server\share\fonts"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFSOfolder = objFSO.GetFolder(strFolder)
Set objFiles = objFSOfolder.Files

For each itmFile In objFiles

If Not objFSO.FileExists("C:\Windows\Fonts\" & itmFile.Name) Then

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(strFolder)
Set objFolderItem = objFolder.ParseName(itmFile.name)

objFolderItem.InvokeVerb("Install")

Set objFolderItem = Nothing
Set objFolder = Nothing
Set objShell =  Nothing

End If

Next

Set objFiles = Nothing
Set objFSOfolder = Nothing
Set objFSO = Nothing

Tags: Script, VBScript, Windows 7

This entry was posted on Tuesday, September 18th, 2012 at 12:33 pm and is filed under Scripts, Windows 7.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

Comments are closed.

  • Donate

  • Channels

    • Beer (2)
    • Blog (1)
    • Exchange (2)
    • Ham Radio (1)
    • Homebrew (3)
    • Linux / Unix (4)
    • Misc (1)
    • Mods (4)
    • Networking (1)
    • Programming (4)
    • Recipes (2)
    • Scripts (7)
    • Security (1)
    • Software (2)
    • Spam (1)
    • Telco (7)
    • Virtual PC (1)
    • VMware (3)
    • VOIP (3)
    • Windows (16)
    • Windows 2008 (4)
    • Windows 7 (5)
  • Archives

    • September 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • November 2011
    • September 2011
    • July 2011
    • April 2011
    • February 2011
    • January 2011
    • October 2010
    • August 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • June 2009
    • May 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Links

    • Blogarama Blogarama – The Blog Directory
    • BlogHub Blog Directory
    • Blogrankings Technology Blogs – Blog Rankings
    • Blogville.us blogville.us
    • Buzzerhut free directory | buzzerhut.com
    • Ontoplist Online Marketing
    • Primechoiceautoparts Discount Auto Parts
    • PTC My Employer
  • Misc

    • Legal Page
 

  Copyright - Bohack 2023 ©