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!

Installing fonts with VB script

Status
Not open for further replies.

KenWK

Programmer
May 25, 2001
76
0
0
US
Hello!

I have some VB and VBA experiance but am brand new to VB Script and Windows 7 (OY!).

I need to install fonts progmatically and found this simple code on another site:
Code:
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Mobilstuff\G_Drive\ttf")
Set objFolderItem = objFolder.ParseName("AGENCYB.TTF")
objFolderItem.InvokeVerb("Install")

Where "C:\Mobilstuff\G_Drive\ttf" is the path of my font file and "AGENCYB.TTF" is the font file itself. This works OK but it would be ideal if I could install the font as a shortcut. I've tried creating a shortcut to the font file and referencing THAT in the script (AGENCYB.TTF.lnk) but Win 7 resolves the shortcut back to the font file and loads it as usual. Which I guess makes sense.

So, my question is kind of two-fold. Is there verb string I can use to install as a shortcut (I've guessed at a few but none have worked) and is there a list of these verb strings somewhere>

Many thanks,
Ken
 
We create and maintain the fonts used for some of the series we do, these fonts include obscure or dead languages like Runic. Therefore, from time to time the client will find symbols on papyri that need to be added to the fonts. Having them installed as shortcuts ensures that when our operators have the font loaded it is coming from the server and not an outdated version they may have loaded on their system prior to any updates.

Usually we do OK with always loading the fonts before beginning on one of these types of projects, but having them installed as shortcuts is a safeguard that ensure they can't be updated when someone is in the middle of using them and that whomever is using them has the latest version.

I guess I should also add to this post is there a way to UN-install the fonts through VBS?

Thanks for taking the time to replay!
 
>is there a list of these verb strings somewhere

Windows maintains a list of these for each folder item, and different folder items will have different lists of applicable verbs. So we can query the object itself for the verbs it can respond to. Here's a simple example:

Code:
[blue]Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Mobilstuff\G_Drive\ttf")
Set objFolderItem = objFolder.ParseName("AGENCYB.TTF")
For Each queryverb In objFolderItem.Verbs
    wscript.echo queryverb.Name
Next[/blue]
 
In the past, I've imported to the registy when adding fonts to several machines. Just create a shortcut to the font and use the shortuct file name when adding the font. Although, I'm sure there is a more elegant way.

Code:
strComputer = "."
strFontName = "Agency Bold"
strShortcut = "c:\local\path\to\shortcut\AGENCYB.TTF.lnk"
set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") 
objReg.SetStringValue HKLM, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", strFontName, strShortcut

-Geates

"I do not offer answers, only considerations."
- Geates's Disclaimer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top