Zeqalox Posted July 8, 2011 Share Posted July 8, 2011 Hi!I saw thread about File Monitoring. It is something I need at the moment!Now Arcker made a sample of how it would work:$strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colMonitoredEvents = $objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _ & "Targetinstance ISA 'CIM_DataFile' and " _ & "TargetInstance.Path = '\\1\\' and " _ & " TargetInstance.Drive = 'C:' ") While 1 $objEventObject = $colMonitoredEvents.NextEvent() Select Case $objEventObject.Path_.Class()="__InstanceCreationEvent" ConsoleWrite ("A new file was just created: " & $objEventObject.TargetInstance.Properties_.Item("Name").Value & @CR) Case $objEventObject.Path_.Class()="__InstanceDeletionEvent" ConsoleWrite ("A file was just deleted: " & $objEventObject.TargetInstance.Properties_.Item("Name").Value & @CR) Case $objEventObject.Path_.Class()="__InstanceModificationEvent" ConsoleWrite ("A file was just modified: " & $objEventObject.TargetInstance.Properties_.Item("Name").Value & @CR) EndSelect WEndI've made some changes to my liking. However, I got stuck!This is the part that the script checks for files being made/changed/deleted:$colMonitoredEvents = $objWMIService.ExecNotificationQuery _ ("Select * From __InstanceOperationEvent WITHIN 5 WHERE " _ & "TargetInstance Isa 'Cim_DataFile' And " _ & "TargetInstance.Path = '\\1\\' And " _ & "TargetInstance.Drive = 'C:'")I need it to check the current userprofile. I just can't get it to work!I tried "TargetInstance.Path = '\\Documents and Settings\\' and a dozen of other methods, but it's just not working!Does somebody know?Thanks in advance! - Zeq Link to comment Share on other sites More sharing options...
Zeqalox Posted July 8, 2011 Author Share Posted July 8, 2011 Nevermind, got it all working after hours and hours of trying stuff Link to comment Share on other sites More sharing options...
Zw0LsDaLe Posted July 9, 2011 Share Posted July 9, 2011 oke maybe you can give the answer here for people like me who came here by search and were hoping for the answer? you have the right script ? of what was the problem? thx Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 9, 2011 Moderators Share Posted July 9, 2011 Zw0LsDaLe, I always use seangriffin's FileSystemMonitor UDF when I need to monitor files and folders. Very reliable and heartily recommended. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now