• 0

[VB] Help copying/installing fonts via command line


Question

I need for users to be able to install fonts to their system without admin privileges at work. We have a system set up that installs software from a defined database that runs as SYSTEM, and that is working well so far.

I had thought that copying font files to the WINDOWS\Fonts directory would be enough to install them, but apparently it is not.

So I found a VB script that copies .ttf files to the Fonts directory using the Windows shell, causing the font to be properly registered. This runs at system startup as SYSTEM, so it has write permission to the directory. All they have to do is copy their new fonts to a directory on the file server and restart their system.

on error resume next
Const FONTS = &H14
dim oFSO, oShell, oFolder1, oFolder2, sRoot
sRoot="\\fileserver\Shared\company\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

The problem is that this only copies files to the local system if they do not already exist there. I had been using robocopy to copy them over, but that wasn't registering them.

So now what I need to do is to figure out how to copy over fonts that are not correctly registered in HKLM\Software\Microsoft\Windows NT\Fonts

Alternatively, I need to be able to automatically delete .ttf files from the local system that are not correctly registered in that same registry key. I definitely don't want to go through the 1,500+ fonts manually.

I also need to be able to copy over .ttf, .otf, .fon and any other font extensions that are possible.

I don't know anything about VB script. Can someone explain how to make that go or write up something that would do that?

6 answers to this question

Recommended Posts

  • 0

Does anyone know of another forum where other experts may be able to assist if nobody here knows? Anyone have a friend who might know the answer? Google's not much help except to teach me VB from scratch, which I'm not really up for just to do this one thing.

  • 0

hi,

the issue here is that putting fonts in the correct folder is not enough to make them work. they need to be registered with the windows registry...

when you double click (or drag) a font into the folder this act registers it with the system..

so, you have two options really..

1. is to execute a registry patch to manually register the font for use

2. reboot the system which i believe will force them to be registered

i think registry patch would be the best way to go... good luck! :)

  • 0

This copies them correctly so that they get registered. This is already doing what needs to be done.

But...

I had copied them wrong in the past using robocopy, so now there are lots of fonts in their Fonts folders that are not correctly registered.

Is there a VB way to view a list from the registry of the fonts that are installed, then skip those when copying fonts over to the computer?

for each regfontname in regkey

if (fontname == regfontname)

continue

else

copy font

or something like that?

(FYI: rebooting doesn't do it. If it did, that would be great, but it doesn't. It has to be copied using the shell, either drag and drop, or using something like this script.)

  • 0

Alternative that we're going to try:

we're going to comment out the 'if not ofso.fileexists' line (and its corresponding end if) and run that. That should hopefully we think maybe copy over all of the fonts whether they need to be copied or not.

Once that has run on each computer, we can uncomment those lines again so that it only installs new fonts when it runs in the future instead of trying to install all 1700 again.

[edit]

Fail.

If the font is already registered, the copy process comes up with an error message. I'm not going to sit and click OK 1,000+ times.

Other thoughts? How can we compare against the registry?

[/edit]

The question remains though:

how can I include more than one file extension? What's the VB command for "or"?

if right(sName,4)=".ttf" or ".otf" or ".fon" then

  • 0
  Quote

how can I include more than one file extension? What's the VB command for "or"?

if right(sName,4)=".ttf" or ".otf" or ".fon" then

 If Right(sName,4) = ".ttf" Or  Right(sName,4) = ".otf"  Or  Right(sName,4) = ".fon" Then
 '-> Your Code Here
 End If

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • OpenAI announces o3 Pro, its most intelligent reasoning model by Pradeep Viswanathan OpenAI today announced o3-pro, its flagship reasoning model that uses more compute to "think harder" and provide consistently better answers. This new model will be replacing o1-pro in ChatGPT since it consistently performs better in math, science, and coding. To help everyone make the most out of the model, o3-pro supports tool calling. So, based on the user prompt, the model can do a web search, analyze files, reason about visual inputs, use Python, personalize responses using memory, and more. This is a big improvement over o1-pro, which lacked access to tools. But the downside is that o3-pro will take more time to respond. OpenAI recommends users use o3-pro in cases where reliability matters more than speed. According to OpenAI's evaluations, users consistently preferred o3-pro's responses over o3 in key domains like science, education, programming, business, and writing help. o3-pro was also rated consistently higher for clarity, comprehensiveness, instruction-following, and accuracy. The new o3-pro model is available in ChatGPT's model picker for Pro and Team. ChatGPT's Enterprise and Edu users will get access to this latest model next week. For developers, the o3-pro model comes with a 200,000 context window and is priced at $20 per million input tokens and $80 per million output tokens. OpenAI recommends developers use background mode with o3-pro to prevent timeouts. And the model has a May 31, 2024 knowledge cutoff. The OpenAI team also noted the following as the current limitations of the o3-pro model: At the moment, temporary chats are disabled for o3-pro as we resolve a technical issue. Image generation is not supported within o3-pro—please use GPT-4o, OpenAI o3, or OpenAI o4-mini to generate images. Canvas is also currently not supported within o3-pro. As OpenAI continues to refine its models, the balance between speed and reliability will likely remain a key consideration for users choosing the right tool for their needs.
    • What annoys me is updates take forever to install on my Pixel 9 Pro XL, it was never so slow on my Samsung devices.
    • Still waiting for Android freaking 15 (One UI 7) on my (supported) Samsung phone and Google is already moving on to 16...
    • PS I just contacted patch for a free trail, But I'm sure that I'm gonna pay for another 5 years of win10 My acer laptop is now almost 6 years old, it's an old school laptop; I can open it with my iFixit toolset, I clean it every 6 months, I can replace a lot parts without any problems it will run another 5 years no matter what. If I need I have the money to buy a frame.work laptop with heavy specs. That will do for a many of years
  • Recent Achievements

    • Reacting Well
      rshit earned a badge
      Reacting Well
    • Reacting Well
      Alan- earned a badge
      Reacting Well
    • Week One Done
      IAMFLUXX earned a badge
      Week One Done
    • One Month Later
      Æhund earned a badge
      One Month Later
    • One Month Later
      CoolRaoul earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      542
    2. 2
      ATLien_0
      269
    3. 3
      +FloatingFatMan
      209
    4. 4
      +Edouard
      203
    5. 5
      snowy owl
      140
  • Tell a friend

    Love Neowin? Tell a friend!