WindowsXP/admin/wmi/wbem/consumers/scripts/itg/extendedeventregistration.wsf
2025-04-27 07:49:33 -04:00

208 lines
4.1 KiB
XML

<Job id="EventRegistration">
<script language="VBScript" src="ExtendedCommonCode.vbs"/>
<script language="VBScript">
'---------------------------------------------------------
'
' File:
'
' Monitor.VBS
'
' Description:
'
' Script file to extend the standard WMI event query language
'
' Author:
'
' Steve Menzies
'
' Date:
'
' 01/12/00
'
' Version:
'
' Draft 1.0
'
'
'---------------------------------------------------------
'
' Function:
'
' ParseQuery
'
' Description:
'
' Parse query language extensions
'
' Input Arguments:
'
' a_Query - Query string to parse
'
' Output Arguments:
'
' None
'
' Return Value:
'
' None
'---------------------------------------------------------
Function ParseQuery ( a_Query , ByRef a_Filter )
ParseQuery = Parser_Success
Dim t_NextPosition
Dim t_PreFilterPosition
Dim t_ParseTree
Dim Status
Status = Create_Empty ( t_ParseTree )
Status = Parser_Select ( DFA_Definition , a_Query , 1 , t_NextPosition , t_ParseTree , t_PreFilterPosition )
If Status = Parser_Success Then
If g_Debug And 8 Then
WScript.Echo "Parser Success"
Dim t_ExpressionString
Status = Traverse_Tree ( t_ParseTree ,t_ExpressionString )
WScript.Echo t_ExpressionString
End If
Status = Type_Evaluate_Tree ( t_ParseTree )
If Status = True Then
If g_Debug And 8 Then
WScript.Echo "Type Evaluation Successful"
WScript.Echo "Reducing Expression"
End If
Dim t_NonConformant
Dim t_Parent
Status = Create_Empty ( t_Parent )
Status = Generate_Conformant_Expression ( t_Parent , t_ParseTree , t_NonConformant )
If Status = True Then
Dim t_ReducedExpression
Status = Traverse_Tree ( t_ParseTree ,t_ReducedExpression )
If g_Debug And 8 Then
WScript.Echo t_ReducedExpression
End If
a_Filter = Mid ( a_Query , 1 , t_PreFilterPosition )
a_Filter = a_Filter + "Where " + t_ReducedExpression
Else
End If
Else
If g_Debug And 8 Then
WScript.Echo "Type Evaluation Error"
End If
End If
Else
WScript.Echo "Parser Failure"
End If
End Function
'---------------------------------------------------------
'
' Function:
'
' Main Function
'
' Description:
'
' Entry point for visual basic script
'
' Input Arguments:
'
' None
'
' Output Arguments:
'
' None
'
' Return Value:
'
' None
'---------------------------------------------------------
dim t_Server
dim t_Namespace
dim t_Query
dim t_Script
Dim t_FilterName
Dim t_ConsumerName
Dim t_Create
Dim t_Test
Dim t_ReturnValue
t_ReturnValue = ParseCommandLine ( g_WshArguments , g_WshArguments.Count , t_Test , t_Create , t_Server , t_Namespace , t_Query , t_Script , t_FilterName , t_ConsumerName )
If t_ReturnValue = Error_Success Then
If t_Test = True or t_Create = True Then
Dim Status
Dim t_FilterQuery
'Status = ParseQuery ( "Select * from __InstanceModificationEvent Within 5.0 where TargetInstance isa ""Win32_LogicalDisk"" or TargetInstance.Steve = 1 Or Another isa ""3"" and Menzies < 3 * 2 + 1 or Ian = 3" , t_FilterQuery )
Status = ParseQuery ( t_Query , t_FilterQuery )
If Status = Parser_Success Then
WScript.Echo t_FilterQuery
If t_Test = True Then
Else
If t_Create = True Then
t_ReturnValue = CreateFilterBindingAndConsumer ( t_Server , t_Namespace , t_FilterQuery , t_Script , t_FilterName , t_ConsumerName )
If t_ReturnValue = Error_Success Then
Else
Wscript.Echo "CreateFilterBindingAndconsumer " , Err.Number, Err.Description
End If
End If
End If
End If
Else
t_ReturnValue = DeleteFilterBindingAndConsumer ( t_Server , t_Namespace , t_FilterName , t_ConsumerName )
If t_ReturnValue = Error_Success Then
Else
Wscript.Echo "DeleteFilterBindingAndconsumer " , Err.Number, Err.Description
End If
End If
Else
Wscript.Echo "ParseCommandLine " , Err.Number, Err.Description
End If
</Script>
</Job>