Need help Vb script copy fonts

Can you help me to create the following script

The users get a error when the font exist.
How can i make a if else, that verifying that the files exist?
If the fonts exist then nothing.
else copy the fonts

Maybe it's better to create a array for the fonts.

Const FONTS = &H14&
 
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
 
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRABK.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRABKIT.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRADM.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRADMCN.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRADMIT.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRAHVIT.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\framd.ttf"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\framd__0.ttf"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRAMDCN.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRAMDIT0.TTF"
	objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\framdit.ttf"

Open in new window

DutchictAsked:
Who is Participating?
 
Shift-3Connect With a Mentor Commented:
This revision only copy files that don't exist in the destination.


Const FONTS = &H14&
 
strSource = "\\2k3svr02\netlogon\deploy_fonts\fonts"
arrFiles = Array("FRABK.TTF", "FRABKIT.TTF", "FRADM.TTF", "FRADMCN.TTF", "FRADMIT.TTF", _
    "FRAHVIT.TTF", "framd.ttf", "framd__0.ttf", "FRAMDCN.TTF", "FRAMDIT0.TTF", "framdit.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
        objFolder.CopyHere strSource & "\" & strFile
    End If
Next

Open in new window

0
 
josepvallsCommented:
Having all the fonts in an array would definitely ease things a lot.

The simple solution would be adding the line:
on error resume next
in the beginning of the script, this will ignore all the errors. After the file copy you can turn error reporting on if you need to run more operations by adding the line:
on error goto 0

Simple solution would be:
if not fso.FileExists(objFolder.self.path+"\FRABK.TTF") objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRABK.TTF"
 
if not fso.FileExists(objFolder.self.path+"\FRABKIT.TTF") objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRABKIT.TTF"

Open in new window

0
 
josepvallsConnect With a Mentor Commented:
Sorry, forgot the then keyword
if not fso.FileExists(objFolder.self.path+"\FRABK.TTF") then objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRABK.TTF"
 
if not fso.FileExists(objFolder.self.path+"\FRABKIT.TTF") then objFolder.CopyHere "\\2k3svr02\netlogon\deploy_fonts\fonts\FRABKIT.TTF"

Open in new window

0
 
DutchictAuthor Commented:
I'm an beginner in scripting understand the solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.