ScriptContext.CreateEvent Method

The CreateEvent method generates a new Event object.

 ScriptContext.CreateEvent()

Return Value

Object (Event)

Remarks

The Event object returned by this method is initially empty. After creating the new Event object, assign a value to it using the ScriptContext.Event property. The Event object can then be sent to the MOM data stream using the ScriptContext.Submit method.

The Event object is the internal representation MOM uses for entries collected from NT Event logs, application log files, and other MOM data providers.

The advantage of creating a MOM event directly in a script is that you can bypass the normal steps MOM uses to collect and process Windows NT event or application log data.

The CreateEvent method is also useful in situations where the script is monitoring a data source that is not supported by one of the built-in MOM data providers.

Creating and Event object with the CreateEvent method will not cause an entry to be added to the Windows NT Event log, or in any other source used by the MOM data provider.

Examples

The following example shows how to generate a new Event object.

Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR   = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function MakeEvent()
    Dim objEvent

    Set objEvent = ScriptContext.CreateEvent()

    objEvent.EventSource = "TestScript"
    objEvent.EventNumber = 1349
    objEvent.EventType = EVENT_TYPE_WARNING
    objEvent.LoggingDomain = "DOMAIN1"
    objEvent.SourceDomain = "DOMAIN1"

    Set MakeEvent = objEvent
End Function

Requirements

Platforms: Requires Windows 2000 or later

Version: Requires MOM 2000 SP1 or later

See Also

ScriptContext Object | ScriptContext.Event Property | ScriptContext.Submit Method | Event Object