I have been using a script to transfer files from several remote servers on
a daily basis. Up till now the script has been functioning as it should,
however I noticed this morning that my script was generating the "Job
Finished" echo way too quickly so I checked the contents of the mapped
shares and found that the files were still there. After commenting out the
"On Error Resume Next" the following error popped up:
Error: File already exist.
Code: 800A003A
Source: Microsoft VBScript runtime error
The line that is referenced is the 'objFileSystemObject.CopyFile' portion
of Sub Transfer. While there are files in that New Directory that might have
the same name, why didn't the OverWriteFiles option ignore this?
Dim objWshNetwork, objWshShell
' On Error Resume Next
Set objWshNetwork = WScript.CreateObject("WScript.Network")
objWshNetwork.RemoveNetworkDrive "m:"
objWshNetwork.MapNetworkDrive "m:", "\\server\share"
Call Transfer
objWshNetwork.RemoveNetworkDrive "m:"
WScript.Echo "Test Finished!"
' Sub routine for moving Audit results from the local DC
Sub Transfer
Dim objFileSystemObject
Set objFileSystemObject = WScript.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSystemObject.GetFolder ("m:\Data")
If objFolder.Files.Count > 0 Then
objFileSystemObject.CopyFile "m:\Data\*.xml",
"T:\New Directory\Data", OverWriteFiles
objFileSystemObject.DeleteFile "m:\Data\*.xml",
Force
End If
End Sub