Does anyone know of a tool were that is service based which I would be able to run a script every time a file arrives in a directory? I would write the script all I want is the tool to be a service based application.
Asked
Active
Viewed 155 times
2 Answers
2
You can write a service using the .NET class FileSystemWatcher. More information is available at this question.
-
and or just create a simple wmi query using the ISA event notification process. still trying to find a good easy example will post when I find one. – tony roth Jul 01 '11 at 20:39
-
@tony roth: Interesting. I'm curious to see your example. – surfasb Jul 01 '11 at 23:27
0
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\cimv2") Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("Select * From __InstanceCreationEvent Within 5 Where " _ & "Targetinstance Isa 'CIM_DirectoryContainsFile' and " _ & "TargetInstance.GroupComponent= " _ & "'Win32_Directory.Name=""c:\\\\scripts""'") Do Set objLatestEvent = colMonitoredEvents.NextEvent Wscript.Echo objLatestEvent.TargetInstance.PartComponent Loop

Ben Pilbrow
- 12,041
- 5
- 36
- 57

tony roth
- 3,884
- 18
- 14