|
-
Feb 1st, 2008, 10:08 AM
#1
Thread Starter
Lively Member
[RESOLVED] Not sure what I'm doing wrong....
The Attached script is designed to copy a single file and distribute it to many different directories on a shared folder, It works fine, although I've come across a couple of errors that I would like to log, the first one is error 76 "File path not found" and the other is error 70 "Permission Denied".
The problem I'm getting is that everytime the script runs it records both errors for the same problem. IE:
K:\Named, Folder\Test Area\ZZZ, Okay2 - Permission Denied
K:\Named, Folder\Test Area\ZZZ, Okay2 - Path not found
K:\Named, Folder\Test Area\ZZZ, Okay3 - Permission Denied
K:\Named, Folder\Test Area\ZZZ, Okay3 - Path not found
Not sure is that is the nature of both Errors or the fact the script is written wrong.
Code:
Dim fso, f, fc, f1, SourceFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set SourceFile = fso.Getfile("K:\Noticeboard\Normalupdates\Normal\Normal.dot")
Set f = fso.GetFolder("K:\Named, Folder\Test Area")
Set fc = f.SubFolders
For Each f1 In fc
If InStr(f1.Name, ",") > 0 Then
On Error Resume Next
SourceFile.Copy f1 & "\Databases\Normal\"
If Err.Number <> 0 Then
Select Case Err.Number ' Evaluate error number.
Case 70 ' "Permission Denied" error.
Case 76 ' "Path not found" error.
mystr = mystr & f1 & " - Permission Denied" & vbNewLine 'add to string here
mystr = mystr & f1 & " - Path not found" & vbNewLine ' add to string here
Err.Clear
Case Else
End Select
Else
End If
On Error GoTo 0
End If
Next
Set f1 = fso.CreateTextFile("K:\Named, Folder\Test Area\ScriptLog.txt", True)
f1.Write mystr
f1.Close
Set f1 = Nothing
Set fso = Nothing
Any help would be greatly appriciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|