The script works perfectly 98% of the time and used to work 100% of the time until recently. Here's the full code:
strComputer = "." 'Local Computer running on this script
set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""U:\\\\UPS_Backup""'") 'Monitor the files in Folder
wscript.Echo "Script Started"
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
strFile = objLatestEvent.TargetInstance.PartComponent
strFile = Replace(Mid(strFile, InStr(strFile, Chr(34)) + 1), "\\", "\")
strFile = Left(strFile, Len(strFile) - 1)
Set CurrFile = objFSO.GetFile(strFile)
CurrFileName = right(strFile, 18)
CurrFileName = left(CurrFileName, 14)
If (Not objFSO.FileExists("U:\UPS_Backup\Archive\" & CurrFileName & ".UPS" ) and Not objFSO.FileExists("U:\UPS_Backup\Archive\" & CurrFileName & ".txt" )) Then
if datevalue(CurrFile.DateCreated) = datevalue(now) Then
objFSO.CopyFile strFile, "U:\UPS_Backup\Archive\"
wscript.sleep(60000)
Else
End If
Else
'wscript.echo "not copying"
End If
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='U:\UPS_Backup\Archive'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFiles
strExtension = objFile.Extension
strExtension = Replace(strExtension, "UPS", "txt")
strNewName = objFile.Drive & objFile.Path & objFile.FileName & "." & strExtension
errResult = objFile.Rename(strNewName)
Next
Loop
wscript.echo "End Script"
wscript.quit