File watcher Script
I want to write a scrip to watch whether the file has come to specified path

Software/Hardware used:
ASKED: October 30, 2007  11:39 AM
UPDATED: May 29, 2008  10:43 AM

Answer Wiki:
Something like this. <pre>Dim filesys,demofile, createdate Set filesys = CreateObject("Scripting.FileSystemObject") ON ERROR RESUME NEXT Setdemofile = filesys.GetFile("filename") IF err.number <> 0 then 'File didn't exist else 'file did exist end if</pre> Alessandro Panzetta Another approach could be a kind of active monitoring on a given folder, that's to say: <pre>Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\.rootcimv2") Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _ & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _ & "TargetInstance.GroupComponent= " _ & "'Win32_Directory.Name=""c:\\scripts""'") Do Set objLatestEvent = colMonitoredEvents.NextEvent Wscript.Echo objLatestEvent.TargetInstance.PartComponent Loop</pre> The script above will monitor file creation in the <i>c:scripts</i> folder and echo a message everytime a file is created. Bye
Last Wiki Answer Submitted:  May 29, 2008  10:43 am  by  alessandro.panzetta   9,695 pts.
All Answer Wiki Contributors:  alessandro.panzetta   9,695 pts. , Denny Cherry   64,550 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _