Windows系统:文件监视脚本(批处理/ VBS) [英] Windows: File Monitoring Script (Batch/VBS)
问题描述
我目前在脚本的工作来创建自定义备份脚本,我错过了唯一的一块是一个文件监控。我需要某种形式的脚本,将监视文件更改一个文件夹,然后用所更改的文件运行命令。
I'm currently in working on a script to create a custom backup script, the only piece I'm missing is a file monitor. I need some form of a script that will monitor a folder for file changes, and then run a command with the file that's changed.
因此,举例来说,如果文件的变化,它会执行C:/syncbatch.bat%Location_Of_File%
So, for example, if the file changes, it'll execute "c:/syncbatch.bat %Location_Of_File%"
在哪里我应该开始任何帮助是极大的AP preciated。非常感谢!
Any help on where I should start is greatly appreciated. Thanks a lot!
推荐答案
在VBScript中,您可以通过订阅WMI <一个监视文件更改文件夹href=\"http://msdn.microsoft.com/en-us/library/aa394651.aspx\"><$c$c>__InstanceModificationEvent$c$c>事件。这些文章包含样本code,你可以从学习和适应您的特定需求:
In VBScript, you can monitor a folder for file changes by subscribing to the WMI __InstanceModificationEvent
event. These articles contain sample code that you can learn from and adapt to your specific needs:
- WMI and File System Monitoring
- How Can I Monitor for Different Types of Events With Just One Script?
这篇关于Windows系统:文件监视脚本(批处理/ VBS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!