Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

RIGHTT!!!!:eek:

 

I have spent about 2.5 hours this afternoon working on trying to install fonts automatically in Windows 7 from a script!

 

So far, I have come up with a basic script that installs the script fine at startup, but it can't seem to check in anyway, whether the font already exists....

 

Can anyone give me some help with my script - its a vbscript, as below:

 

[b][i]' Fonts.installer
' ----------------------------------------------------------
Option Explicit

Dim objShell, objFolder

Const FONTS = &H14&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "\\%server%\%sharename%\!Y2KBUG.ttf"

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "\\%server%\%sharename%\$FIVEDOU.ttf"

Wscript.Quit[/i][/b]

 

I don't know if it is something special to do with the Windows/Fonts directory in Windows 7, but nothing I do, can seem to check the exisitance of a font already in the directory....

 

Can anyone help!

 

Cheers

_techie_

Posted
So far, I have come up with a basic script that installs the script fine at startup, but it can't seem to check in anyway, whether the font already exists....

 

Can anyone give me some help with my script - its a vbscript, as below:

 

 

Can you show the code you're trying to use to check if they exist? Easier to see if something's wrong if you post it :D

 

Steve

Posted
I have posted the code in my previous post.

 

^^^ Cheers

_techie_

 

Well you haven't checked if files exist at all... Nor do you have any variables etc etc :p

 

So did you try to check it, or prefer just full version posted? :p Don't mind either way

 

Try this:

 

On error resume next
dim fontlist(3),root,path,check,filelist
fontlist(0)="font1.TTF"
fontlist(1)="font2.TTF"
fontlist(2)="font3.TTF"
fontlist(3)="font4.TTF"

Set fso = CreateObject("Scripting.FileSystemObject") 
filepath = fso.GetParentFolderName(wscript.ScriptFullName)

set wshShell = Wscript.CreateObject("Wscript.shell")
fontpath = wshShell.ExpandEnvironmentStrings("%windir%")

Const FONTS = &H14&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)

for each font in fontlist
copyto=filepath+"\"+font
check_file=fontpath+"\fonts\"+font
if fso.FileExists(check_file) then
	root=0
else
	objFolder.CopyHere copyto
end if
next

 

Steve

Posted

Here is a script that works.

Const FONTS = &H14&

Dim wsh
Set wsh = WScript.CreateObject("Wscript.Shell")

function LogtoEvent (MSG,success)
select case success
	case 1	wsh.LogEvent EVENT_SUCCESS, MSG ' 1 is a success
	case 0	wsh.LogEvent EVENT_FAILURE, MSG ' 0 is a error
	case 2	wsh.LogEvent EVENT_WARNING, MSG ' 2 is a warning
	case 3	wsh.LogEvent EVENT_INFORMATION, MSG ' do not use
end select
end function
LogtoEvent "INSTALL FONTS: Started Installing Fonts",1

strSource = "\\{UNC PATH TO DIR WITH FONTS}"
arrFiles = Array("{FONT NAME.ttf", "{ANOTHER FONT NAME.ttf}")

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)

For Each strFile in arrFiles
   Set objFolderItem = objFolder.ParseName(strFile)
   
   If objFolderItem is nothing Then
   	LogtoEvent "INSTALL FONTS: Installing " & strFile,1
       objFolder.CopyHere strSource & "\" & strFile, &H4&
   End If
Next

LogtoEvent "INSTALL FONTS: Done",1

 

This leaves entries in the event log too ftw :)

Posted

in answer to steve21

 

well..I ran a BAT file with the following:

 

@echo OFF

IF EXIST "C:\WINDOWS\Fonts\!Y2KBUG.ttf" GOTO END

wscript.exe "C:\font_installer.vbs"

:End

ECHO Font installed correctly

 

However...this just went straight to End immediately!

If I just run the wscript.exe part it installs the fonts fine, but just repeats the issue everytime the bat file runs :-(

Posted
i just used winstall and made an msi that has worked for me in he past if i needed to get fonts to a win7 box
  • 3 months later...

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...