Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, October 28, 2015 11:23 AM
Hello,
I'm trying to install a bunch of fonts using vb or powershell. I understand that it's not enough to just copy the fonts to C:\windows\fonts these days. I've been having problems using the shell.application object though. If I run:
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\fonts")
Set objFolderItem = objFolder.ParseName("sbd_____.pfm")
Nothing happens, with either otf,ttf or .pfm fonts. The fonts are copied to the fonts folder but don't show up in apps or in the registry.
The fonts only install if I add : objFolderItem.InvokeVerb("Install")
Is this line literally doign the same thing as i do if I manually install the font when right clicking the file?
My powershell script looks like :
$FONTS = 0x14
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($FONTS)
$objFolder.CopyHere("C:\fonts\vagroundedstd-thin.otf")
Can I add the command objFolderItem.InvokeVerb("Install")? Or is there another install command for powershell?
All replies (11)
Wednesday, October 28, 2015 12:14 PM | 1 vote
Hi,
There are many examples here:
https://duckduckgo.com/?q=install+fonts+with+powershell
Wednesday, October 28, 2015 12:31 PM
ok, so I found that the font files have a list of verbs including &InstallI think I can use the invoke command to run the Install option in the contextual menu for the font.Not sure what the correct syntax is though?
Wednesday, October 28, 2015 12:54 PM
start-process $fontname -Verb install
\(ツ)_/
Wednesday, October 28, 2015 1:08 PM
Thanks, I've already run through a lot of the articles available online. My main problem is that even using the shell.application to add the fonts they're still not available in any apps. I get the same results in powershell and vb.
Running the invokeverb command in vb does the trick, just looking for a way to do the same in powershell.
jrv, thanks for that, that looks like what I'm after but when I run it, it says that there's no application associated with the file. Can I use invoke item along with -Verb install? Just tried it but not sure if I'm entering it right.
Wednesday, October 28, 2015 1:32 PM
$code=@'
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
public static class FontUtil{
[DllImport("gdi32.dll")]
public static extern int AddFontResource(string lpFilename);
}
'@
Add-Type $code
[fontutil]::AddFontResource('c:\windoows\fonts\verdana.ttf')
\(ツ)_/
Wednesday, October 28, 2015 2:12 PM
Could you explain what that's doing please? Not sure what the green code is doing...You're adding verdana at the bottom to the font folder but where are you getting it from?
Will this font be installed permanently?
Thanks
Wednesday, October 28, 2015 2:20 PM
It is the function that the shell verb calls.
I added the font as a reference too show how to use the function.
\(ツ)_/
Wednesday, October 28, 2015 2:29 PM
So...
I've changed it to : [fontutil]::AddFontResource('c:\fonts\vagroundedstd-black.otf')as I'm testing installing fonts from a local folder.....I ran teh script in the ISE and it returned a 1.
Can't see my font in the win font folder though?
Sorry to be a pain, I've tried numerous scripts and I'm slowly getting to know powershell and vb, I've been thrown in at the deep end here.
Thanks again.
Wednesday, October 28, 2015 2:43 PM
The font file has to be copied to a font folder first. THe font folder is really not a folder. It is special store where fonts are registered and loaded from.
\(ツ)_/
Wednesday, October 28, 2015 3:02 PM
Right, but as I understand it, If I use the shell.application it'll register the fonts and install them correctly.
This doesn't seem to be workign though.....
Which is why I was looking for a way to directly "click" the install menu item on each font I want to install.
This works in VB but what's the equivalent in Powershell?
objFolderItem.InvokeVerb("Install")
Wednesday, April 6, 2016 9:41 PM
Right, but as I understand it, If I use the shell.application it'll register the fonts and install them correctly.
This doesn't seem to be workign though.....
Which is why I was looking for a way to directly "click" the install menu item on each font I want to install.
This works in VB but what's the equivalent in Powershell?
objFolderItem.InvokeVerb("Install")
If you haven't figured it out yet, here is my dirty script to install a set of fonts in a folder. Can use SCCM to deploy the package and run the script
$path = "$pwd\Fonts"$shell = New-Object -ComObject Shell.Application$shell.Namespace($path).Items().InvokeVerbEx("Install")
In the source folder I have the following:
.\installFonts.ps1
.\Fonts
.\Fonts\font files>