smarttmelanie
03-31-2004, 03:49 PM
When I run the script below, it will tell me if a file has been created in the C: drive called 'Inspections.txt'. What I need is a script that will notify me if a file (without an extension) is created called 'Inspection' and for it to notify me if it has been created anywhere in the C: drive not just the root. PLEASE HELP...MY JOB DEPENDS ON IT
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\""'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
x = Instr(objLatestEvent.TargetInstance.PartComponent,"Inspections.txt")
If x <> 0 Then
Wscript.Echo objLatestEvent.TargetInstance.PartComponent
End If
Loop
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\""'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
x = Instr(objLatestEvent.TargetInstance.PartComponent,"Inspections.txt")
If x <> 0 Then
Wscript.Echo objLatestEvent.TargetInstance.PartComponent
End If
Loop