0

I found a script for install fonts and I edited it to install some fonts (array of fonts) alongside but it doesn't run. This line raises an error:

array.InvokeVerb("Install")

It seems to replace InvokeVerb with another function but I dont know!

Can some one help me?

My script:

Option Explicit
'Installing multiple Fonts in Windows 7

Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile
Dim array : Set array = CreateObject("System.Collections.ArrayList")

Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject")

strFontSourcePath = "C:\Users\Win7\Desktop\new_Software\Fonts"

If objFSO.FolderExists(strFontSourcePath) Then
  Set objNameSpace = objShell.Namespace(strFontSourcePath)
  Set objFolder = objFSO.GetFolder(strFontSourcePath)

  For Each objFile In objFolder.Files
    If LCase(Right(objFile,4)) = ".ttf" Or LCase(Right(objFile,4)) = ".otf" Then
      array.Add objNameSpace.ParseName(objFile.Name)
    End If
  Next
  array.InvokeVerb("Install")
Else
  WScript.Echo "Font Source Path does not exists"
End If
1
  • 1
    You need to do the InvokeVerb in the For ... Next loop. Commented Mar 11, 2018 at 1:43

1 Answer 1

1

ArrayList objects don't have an InvokeVerb method, and VBScript doesn't provide member enumeration like PowerShell does (which would allow the interpreter to invoke the method on the array items rahter than the array itself).

As ACatInLove already mentioned you need to use a For Each loop to enumerate the array elements and invoke the method on each element:

For Each el In array
  el.InvokeVerb("install")
Next
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.