|
-
February 17th, 2007, 08:09 AM
#1
WMI: File creation notification
Hello,
I need a WMI query that will notify me whenever a new file is created inside specific directory OR any of its subdirectories.
I tried to catch __InstanceCreationEvent for CIM_DataFile, but that didn't work... Then I tried to catch the same event for CIM_DirectoryContainsFile. That one worked, but I couldn't make it control the subdirectories - it controlled only the directory itself...
Can you help me with the query?
Last edited by Dmitry Perets; February 17th, 2007 at 08:12 AM.
-
February 17th, 2007, 08:17 AM
#2
Re: WMI: File creation notification
So are you wanting the whole subdirectory tree or just one folder deep into the tree? Either way, you are going to have to personally query CIM_DirectoryContainsFile for each folder that you want to monitor. This will involve recursive directory monitoring which will slow down a machine significantly if you plan to update the search often.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
February 17th, 2007, 09:03 AM
#3
Re: WMI: File creation notification
 Originally Posted by PeejAvery
So are you wanting the whole subdirectory tree or just one folder deep into the tree? Either way, you are going to have to personally query CIM_DirectoryContainsFile for each folder that you want to monitor. This will involve recursive directory monitoring which will slow down a machine significantly if you plan to update the search often.
I want the whole subdirectory tree. Subdirectories, sub-subdirectories and so on. Isn't there any better way to query that? I mean, each time when a file is being created, some event is being rised, and it has the path of the newly created file. Can't I just ask something like:
SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'File' WHERE TargetInstance.Path StartsWith 'C:\Test'?
-
February 17th, 2007, 01:45 PM
#4
Re: WMI: File creation notification
 Originally Posted by Dmitry Perets
SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'File' WHERE TargetInstance.Path StartsWith 'C:\Test'?
Can you try using LIKE 'C:\Test%'?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
February 18th, 2007, 08:22 AM
#5
Re: WMI: File creation notification
 Originally Posted by PeejAvery
Can you try using LIKE 'C:\Test%'?
I tried... It just hags up...
-
February 18th, 2007, 08:51 AM
#6
Re: WMI: File creation notification
 Originally Posted by Dmitry Perets
It just hags up...
If you refer back to my first post, that is part of what I tried to explain to you. Monitoring so many folders will use so many resources and hard disk spin time that it is practically impossible. You can create an index, such as a file search program would do, but I think you have to hook window messages in order to see if they are saving a new file.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
February 18th, 2007, 09:45 AM
#7
Re: WMI: File creation notification
-
February 18th, 2007, 05:53 PM
#8
Re: WMI: File creation notification
Sorry that things could not work out to your liking.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|