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.panzetta9,695 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.