Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.