11

Is it possible to start a script every time a folder tree is modified.

E.g.:

root
  dir1
    file1
  dir2
    file1
    file2

root would be listened and if, for example, file2 is modified or a new file is added wherever in the directory tree, a script is started.

A subquestion would be : are scheduled tasks triggered by events queued ?

Thanks for your help!

2 Answers 2

8

You can certainly do this using Powershell and WMI Events.

Here's a link that describes setting up PowerShell to monitor events.

http://www.pavleck.net/powershell-cookbook/ch31.html (Wayback Link, as it appeared 5 Nov 2013)

Here's a link that describes the kind of events you'll be looking for:

http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/04/how-can-i-monitor-for-different-types-of-events-with-just-one-script.aspx

2

You can trigger a task based on an event that is logged to the event log, however there is no functionality that will create an event based on a new file being created or a file being modified.

You could use object access tracking events (from the security log) to a certain degree, but since they generate a lot of noise, it's unlikely that this would work very well.

You can use a 3rd party product (free version available) EventSentry to accomplish this however - either in combination with the task scheduler, or stand-alone. It includes a file monitoring feature that will log events to the event log when a file is added, changed, or removed (including checksum changes). You can then trigger a process based on the event that was logged.

There is also a free version (EventSentry Light) that you could use in combination with the Task Scheduler. EventSentry Light will first generate the event based on file monitoring (in the application event log), and you can then use that as the trigger to the task scheduler.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .