Can I trigger a scheduled task when the contents of a folder change?


  1. Posts : 51
    Windows 7 Home Premium 64bit
       #1

    Can I trigger a scheduled task when the contents of a folder change?


    Hello everyone,

    I want to use the windows task scheduler to run a task when something is copied to a folder on my server. When this happens several programs run and extract files, rename them and move them automatically.

    Right now I have the window task scheduler running a task every 5 minutes on this folder so when something get's copied into it the files will be processed, however this is a really bad way of doing this. I saw under the task scheduler trigger I could begin the task on an event and that I could create a filter based on something.

    The problem is I don't know if there is anything that can be used when a folder changes. I have attached a picture showing the trigger and filter screen so you can see what I am talking about. Is there something on the right (encircled with red) that I could use?

    I know that there are a lot of ways of doing this (monitoring a folder) and a lot of other programs that will "just do it for you", but I would like to come up with a solution using windows task scheduler if possible.

    Thank you in advance for your help.
    -S
    Attached Thumbnails Attached Thumbnails Can I trigger a scheduled task when the contents of a folder change?-task-scheduler.jpg  
      My Computer


  2. Posts : 51
    Windows 7 Home Premium 64bit
    Thread Starter
       #2

    Well I guess this must not be done very often as still no replies. If a mod thinks this should be in a different forum could you let me know? If someone knows of a forum that would be better I would love to hear about it.

    Thanks again for any help you can provide.

    -S
      My Computer


  3. Posts : 2
    windows 7 Enterprise
       #3

    Same problem but...


    Hi nzdreamer55,

    I am a software engineer. I was looking for an easy solution to do exactly what you want, but it looks like very few people need this. So I am going to work on it tonight. I will let you know what I find out.

    Serge
      My Computer


  4. Posts : 1
    Windows 8.1 64
       #4

    Dude, did you manage to get the correct answer from anybody? I need exactly the same thing. Thanks
      My Computer


  5. Posts : 2
    windows 7 Enterprise
       #5

    Sorry but I do not recall what happened regarding this project. I either got too busy with more important issues or found that you can't do this with Window Scheduler.
    The following article confirms the second possibility is true:
    Build a 'Folder Watcher' Service in C# | .NET Framework content from Dev Pro
      My Computer


  6. Posts : 5,092
    Windows 7 32 bit
       #6

    I hope the server is mostly idle. Any time I tried anything that automatically detected folder changes it bogged the entire system by hogging the HD. It relentlessly checks every file in the folder tree to see if the modification,access times etc.. are the same as last time. If you have thousands of files in that folder tree you can see why the system would bog.

    For this type of stuff to work smoothly I suspect the file system needs to be implemented as a true relational database. Then changes are logged as they happen. No big performance hit.

    I don't know any Windows file system that fits that description though. :)

    Edit: Long story short, you are probably better off polling every so many minutes.
      My Computer


  7. Posts : 1,049
    Windows 7 Pro 32
       #7

    Here's an VBS example that uses WMI to subscribe to file changes in a folder: New, changed, deleted
    I've tried it briefly without problems.

    WMI and File System Monitoring - CodeProject
      My Computer


  8. Posts : 1,049
    Windows 7 Pro 32
       #8

    And if you modify the above VBS example to write a specific event in the event log instead of alerting messages, you can then set a trigger for this new event in a scheduled task. Example:

    VB Script to write an event with specific eventID and eventSource into eventlog
      My Computer


  9. Posts : 5,092
    Windows 7 32 bit
       #9

    WMI may work a bit better. But I know for a fact the WinAPI for file change notification is a dog. :) You have more leeway with a server to be sure. Running the WinAPI call on the workstation is a disaster.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 08:39.
Find Us