Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

So, for example, if the file changes, it'll execute "c:/syncbatch.bat %Location_Of_File%"

like image 228
Dustin Avatar asked Apr 23 '11 03:04

Dustin


1 Answers

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?
like image 115
Helen Avatar answered Sep 30 '22 18:09

Helen