Link to home
Start Free TrialLog in
Avatar of Dutchict
Dutchict

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dutchict
Dutchict

ASKER

I'm an beginner in scripting understand the solution.