' Region Description ' ' Name: ' Author: ' Version: ' Description: ' ' ' EndRegion strSource = "C:\test" strDest = "C:\test2" bOVERWRITE = vbTrue strComputer = "." Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2") Set colEvents = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _ & "Targetinstance ISA 'CIM_DirectoryContainsFile' AND " _ & "TargetInstance.GroupComponent= " _ & "'Win32_Directory.Name=""" & formPath(strSource) & """'") Do While True Set objEvent = colEvents.NextEvent() copyFile(objEvent.TargetInstance.PartComponent) Loop Sub copyFile(strFile) On Error Resume Next Set objFso = CreateObject("Scripting.FileSystemObject") Set objFile = objFso.GetFile(cleanPath(strFile)) Err.Clear objFile.Copy strDest, bOVERWRITE If Err.number <> 0 Then logError objFso, objFile.Name Set objFile = Nothing Set objFso = Nothing End Sub Function formPath(strPath) formPath = Replace(strPath, "\", "\\") End Function Function cleanPath(strWMIpath) strPath = Right(strWMIpath, Len(strWMIpath) - InStr(strWMIpath, "=")) strPath = Left(strPath, Len(strPath) - 1) strPath = Right(strPath, Len(strPath) - 1) strPath = Replace(strPath, "\\", "\") parsePath = strPath End Function Sub logError(ByRef objFso, strFile) Set objLogFile = objFso.OpenTextFile("errorlog.txt", 8, vbTrue) objLogFile.WriteLine Now() & " Error copying " & strFile objLogFile.Close End Sub