现在的问题是:
可以完美监控文件夹内 文件的 建立 删除 重命名
但是无法监控文件的修改
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colMonitoredEvents = $objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\""'")
While 1
$objEventObject = $colMonitoredEvents.NextEvent()
Select
Case $objEventObject.Path_.Class() = "__InstanceCreationEvent"
ConsoleWrite("created" & $objEventObject.TargetInstance.PartComponent())
Case $objEventObject.Path_.Class() = "__InstanceDeletionEvent"
ConsoleWrite("deleted" & $objEventObject.TargetInstance.PartComponent())
Case $objEventObject.Path_.Class() = "__InstanceModificationEvent"
ConsoleWrite("modify" & $objEventObject.TargetInstance.PartComponent())
EndSelect
WEnd
但是 这一条:
Case $objEventObject.Path_.Class() = "__InstanceModificationEvent"
ConsoleWrite("modify" & $objEventObject.TargetInstance.PartComponent())
不是起的就是监控修改的么?
请教达人... |