Listing04_Event_Notification (VBScript)
This code can be found in
Chapter 5 of Managing Enterprise Active Directory Services
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' From the book "Managing Enterprise Active Directory Services"
' ISBN: 0-672-32125-4
On Error Resume Next
Dim wmi_path, wql_query
wmi_path = "winmgmts:{(security)}"
wql_query = " select * " & _
" from __instancecreationevent" & _
" where targetinstance isa 'Win32_NTLogEvent'" & _
" and targetinstance.LogFile = 'System'" & _
" and targetinstance.EventIdentifier = 5778 "
set events = GetObject(wmi_path).ExecNotificationQuery(wql_query)
if err <> 0 then
WScript.Echo Err.Description, Err.Number, Err.Source
end if
WScript.Echo ""
WScript.Echo "Waiting for NT Event..."
WScript.Echo ""
do
set NTEvent = events.NextEvent if err <> 0 then
WScript.Echo Err.Number, Err.Description, Err.Source
Exit Do
else
WScript.Echo "Log: " & NTEvent.TargetInstance.LogFile
WScript.Echo "EventID: " & NTEvent.TargetInstance.EventIdentifier
WScript.Echo "Message: " & NTEvent.TargetInstance.Message
WScript.Echo "Time: " & NTEvent.TargetInstance.TimeGenerated
WScript.Echo ""
end if
loop
|
This code has been viewed 1021 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|