Jump to content

Recommended Posts

Posted

I am sure I got this script from Edugeek, possibly from @Arthur but not sure.

 

I used it previously as a startup script at our Primary School and now I want to do the same on my own School network but the fonts just don't get installed.

 

Option Explicit
' Installing multiple Fonts in Windows 7 
Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile 
Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject") 
rem Wscript.Echo "--------------------------------------"
rem Wscript.Echo " Install Fonts "rem Wscript.Echo "--------------------------------------"
rem Wscript.Echo " " 

strFontSourcePath = "\\server\shared$\IT Support\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
       If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
           rem Wscript.Echo "Font already installed: " & objFile.Name
       Else
           Set objFont = objNameSpace.ParseName(objFile.Name)
           objFont.InvokeVerb("Install")
           rem Wscript.Echo "Installed Font: " & objFile.Name
           Set objFont = Nothing
       End If
   End If 
  Next
   Else
       Wscript.Echo "Font Source Path does not exists"
   End If

Posted

How long is a piece of string? :getmecoat:

 

But in all seriousness, could be a million and one things. The obvious few to check would be do your computer/system accounts have access to said share? (aka not a logged in user etc).

 

Does it work if you run it as a local admin while logged in ok? Just not as startup?

 

Steve

Posted
How long is a piece of string? :getmecoat:

 

But in all seriousness, could be a million and one things. The obvious few to check would be do your computer/system accounts have access to said share? (aka not a logged in user etc).

 

Does it work if you run it as a local admin while logged in ok? Just not as startup?

 

Steve

 

Seems to work if I run it manually. I have made 'Everyone' Group have read/write access to that share but it still doesnt install.

Posted (edited)

If you run this version (As start up I mean), and then check in event logs once you log in under Application logs what's it show:

 

Option Explicit
' Installing multiple Fonts in Windows 7 
Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile 
Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject") 

wshshell.LogEvent 4, "Installing Fonts"

strFontSourcePath = "\\server\shared$\IT Support\Fonts" 

If objFSO.FolderExists(strFontSourcePath) Then 
wshshell.LogEvent 4, "Folder Found"

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
       If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
           wshshell.LogEvent 4, "Font already installed: " & objFile.Name
       Else
           Set objFont = objNameSpace.ParseName(objFile.Name)
           objFont.InvokeVerb("Install")
           wshshell.LogEvent 4, "Installed Font: " & objFile.Name
           Set objFont = Nothing
       End If
   End If 
  Next
   Else
       wshshell.LogEvent 4, "Folder Not Found"
   End If

if err.number <> 0 then
wshshell.LogEvent 4, err.source & " - " & err.description
end if

 

Steve

Edited by Steve21
Posted (edited)
I am sure I got this script from Edugeek, possibly from Arthur but not sure.

I haven't written a VBScript for a really long time. I don't think it was me. :)

 

Your script looks like the VBScript shown in this blog post which doesn't work properly due to a bug in Windows when installing fonts under the SYSTEM account.

 

You might find the PowerShell script mentioned in the following post more useful...

 

www.edugeek.net/forums/windows-7/123187-installation-fonts-without-admin-rights-2.html#post1630831

 

If you run @Steve21's script you will probably notice that "objFile.Name" doesn't contain a file extension due to the aforementioned bug.

Edited by Arthur
  • Thanks 1
Posted
I haven't written a VBScript for a really long time. I don't think it was me. :)

 

Your script looks like the VBScript shown in this blog post which doesn't work properly due to a bug in Windows when installing fonts under the SYSTEM account.

 

You might find the PowerShell script mentioned in the following post more useful...

 

www.edugeek.net/forums/windows-7/123187-installation-fonts-without-admin-rights-2.html#post1630831

 

If you run @Steve21's script you will probably notice that "objFile.Name" doesn't contain a file extension due to the aforementioned bug.

Not very good with Powershell but is this all I need? Where would I point it to my folder of fonts I want installed?

 

[color=#333333]$Shell = New-Object -ComObject Shell.Application[/color]ForEach ($Font in $Shell.Namespace($PSScriptRoot).Items()) {

   $FileName = [iO.Path]::GetFileName($Font.Path)

   if ($FileName -match '\.(ttf|otf|pfm|fon)$') {

       if (-not(Test-Path ($env:windir + "\Fonts\" + $FileName) -ErrorAction SilentlyContinue)) {

           $Font.InvokeVerbEx("Install")

       }

   }

[color=#333333]}[/color]

Posted (edited)
Not very good with Powershell but is this all I need? Where would I point it to my folder of fonts I want installed?

The script linked in post #5 is designed to be run from the same folder as the fonts, so I have modified it slightly to do what you need. Just change the UNC path shown in red below. :)

 

$FontSource = "[color="#FF0000"]\\Server\Shared$\IT Support\Fonts[/color]"

$Shell = New-Object -ComObject Shell.Application

ForEach ($Font in $Shell.Namespace("$FontSource").Items()) {

   $FileName = [iO.Path]::GetFileName($Font.Path)

   if ($FileName -match '\.(ttf|otf|pfm|fon)$') {

       if (-not(Test-Path ($env:windir + "\Fonts\" + $FileName) -ErrorAction SilentlyContinue)) {

           Write-Output "Installing $($FileName)"
           $Font.InvokeVerbEx("Install")

       }
   }
}

Edited by Arthur
  • Thanks 1
Posted

Is there a reason not to use Group Policy to dump the files in the right place and create the registry settings? That's what we do.

 

%systemroot%\fonts

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]

""="filename.ttf"

  • Thanks 1
Posted
Is there a reason not to use Group Policy to dump the files in the right place and create the registry settings? That's what we do.

 

%systemroot%\fonts

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]

""="filename.ttf"

 

I wanted to have a central folder where staff could dump fonts that they want installed and then the script picks them up and installs them.

Posted
This is the script we use, I take no credit for the making of it as I found it online.

 

All we had to do was dump the fonts in a shared folder where it is accessible to Staff and get this to run on login/start up etc.

 

[ATTACH]49455[/ATTACH]

 

Just realised I contradicted myself by saying we do not use scripts then said what script we use, what I meant was we Used to use the attached script at my previous school which did sometimes have some issues so went onto using MSI. However give it a go as it may just work for others.

Posted
Just realised I contradicted myself by saying we do not use scripts then said what script we use, what I meant was we Used to use the attached script at my previous school which did sometimes have some issues so went onto using MSI. However give it a go as it may just work for others.

 

That's the exact same script I posted to say I couldn't get it to work!

Posted
That's the exact same script I posted to say I couldn't get it to work!

Haha ok then, cannot even remember where I found it, must have been about three years ago when I used it last but it did sort of work.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...