?
Solved

Need help Vb script copy fonts

Posted on 2009-02-13
4
Medium Priority
?
910 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:Dutchict
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 900 total points
ID: 23633662
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
 
LVL 1

Expert Comment

by:josepvalls
ID: 23633666
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
 
LVL 1

Assisted Solution

by:josepvalls
josepvalls earned 600 total points
ID: 23633678
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
 

Author Closing Comment

by:Dutchict
ID: 31546710
I'm an beginner in scripting understand the solution.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question