用于监控文件更改的WQL查询
由于我是 WMI 事件的新手,因此我需要一些帮助。 我正在尝试编写 WQL 查询来监视文件中发生的任何更改 放置在特定文件夹(C:\Data)中 我提出了以下查询,但 WMIEvent 从未发生。
SELECT * FROM __InstanceModificationEvent WITHIN 1 WHERE TargetInstance ISA "CIM_DataFile" AND TargetInstance.Drive="C:" AND TargetInstance.Path="\\Data"
请您向我提供任何反馈,我做错了什么,或者如果您知道查询文件更改的其他方式,我也将不胜感激:)
I need some help since I am new to WMI Events.
I am trying to write WQL query for monitoring any changes that occure in a file
that is placed in specific folder(C:\Data)
I come up with the following query,but WMIEvent never occures.
SELECT * FROM __InstanceModificationEvent WITHIN 1 WHERE TargetInstance ISA "CIM_DataFile" AND TargetInstance.Drive="C:" AND TargetInstance.Path="\\Data"
Please can you provide me any feedback, what I do wrong or if you know other way to query for file changes I'll appreciate it as well :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于您没有将查询中的 \ 字符加倍。 \ 是 WQL 中的保留字符,因此必须使用 \ 代替。 下面是我使用的 VBScipt,并且能够正常工作。 我希望这是有帮助的!
您可能还有兴趣了解如何使用 FileSystemWatcher 通过某些 .NET 语言(例如 VB.NET 或 C#)执行相同的操作。
I think the problem is that you didn't double up the \ characters in your query. \ is a reserved character in WQL so you must use \ instead. Below is the VBScipt I used and was able to get working. I hope this is helpful!
You might also be interested in looking at using the FileSystemWatcher via some .NET language (such as VB.NET or C#) to do the same.