http://dieseyer.de • all rights reserved • © 2011 v11.4

Option Explicit

Dim Tst
Tst = "c:\1test"
Tst = "D:\temp.zw\"
Tst = "D:\temp.zw"
Tst = FileCreationEvent( ".", Tst )
MsgBox "=>" & Tst & "<=", , "0005 :: "

'**************************************************************
Function FileCreationEvent( PC, FolderOnPC)
'**************************************************************
Dim Txt
FolderOnPC = Replace( FolderOnPC, "\", "\\\\" )
' MsgBox "FolderOnPC: " & FolderOnPC, , "0012 :: "
Dim objWMIService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & PC & "\root\cimv2")
Dim colMonitoredEvents : Set colMonitoredEvents = objWMIService.ExecNotificationQuery ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=""" & FolderOnPC & """'")
Txt = ""
Dim objLatestEvent
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Txt = Txt & vbCRLF & Now() & vbTab & objLatestEvent.TargetInstance.PartComponent
MsgBox Txt, 4096, "0020 :: "
Loop
End Function ' FileCreationEvent( PC, FolderOnPC)

http://dieseyer.de • all rights reserved • © 2011 v11.4