找回密码
 加入
搜索
查看: 1761|回复: 2

关于文件夹监控...

[复制链接]
发表于 2008-12-4 16:37:12 | 显示全部楼层 |阅读模式
现在的问题是:
可以完美监控文件夹内 文件的 建立 删除 重命名
但是无法监控文件的修改
$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())


不是起的就是监控修改的么?

请教达人...
发表于 2008-12-4 19:03:48 | 显示全部楼层
不喜欢WMI
发表于 2008-12-4 21:01:27 | 显示全部楼层
换个思路,监控文件的时间,如果时间相对上次的的时间变了,而其它的没有变,应该就是修改了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 09:27 , Processed in 0.079377 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表