Jump to content

monitor directory


Recommended Posts

hello,

try to monitor several directory that receive files randomly.

Encounter problem when 1 file come in and 1 file is deleted, so i can't take number of files as valid check,

Think to use size (kb) of directory, but don't know how to monitor this... (and its performance)

any brillant idea to script valid directory monitor ?

thank you,

m.

Link to comment
Share on other sites

Sysinternals - www.sysinternals.com

Filemon

Filemon is an application that monitors and displays all file system activity on a system. It has advanced filtering and search capabilities that make it a powerful tool for exploring the way Windows works, seeing how applications use the files and DLLs, or tracking down problems in system or application configurations. 

Link to comment
Share on other sites

thats nice, didnt know that api calls also were already available in autoit.

i use this vb script when needed(WMI)

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceOperationEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\scripts""'")
 
Do While TRUE
    Set objEventObject = colMonitoredEvents.NextEvent()

    Select Case objEventObject.Path_.Class
        Case "__InstanceCreationEvent"
            Wscript.Echo "A new file was just created: " & _
                objEventObject.TargetInstance.PartComponent
        Case "__InstanceDeletionEvent"
            Wscript.Echo "A file was just deleted: " & _
                objEventObject.TargetInstance.PartComponent
    End Select
Loop

PS: this monitors only creation and deletion! probably u can query size and then monitor for size change... this is from ms website raw code. mine does have adaptation to my requiremnts..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...