SWbemEventSource オブジェクト

SWbemEventSource オブジェクトは、SWbemServices.ExecNotificationQuery と組み合わせてイベント クエリからイベントを取得します。 SWbemServices.ExecNotificationQuery を呼び出してイベント クエリを行うと、SWbemEventSource オブジェクトが取得されます。 その後NextEvent メソッドを使用して、イベントが到着したときにイベントを取得できます。 このオブジェクトは、VBScript の CreateObject 呼び出しでは作成できません。

メンバー

SWbemEventSource オブジェクトには、次の種類のメンバーがあります。

メソッド

SWbemEventSource オブジェクトには、次のメソッドがあります。

メソッド 説明
NextEvent SWbemServices.ExecNotificationQuery と組み合わせてイベントを取得するために使用します。

プロパティ

SWbemEventSource オブジェクトには、次のプロパティがあります。

プロパティ アクセスの種類 説明
Security_
読み取り専用
セキュリティ設定の読み取りまたは変更に使用します。

このスクリプトでは、SWbemEventSource クラスと SWbemServices クラスのメソッドを、アプリケーション イベントの WQL クエリと組み合わせて使用します。 WMI イベント通知とクエリの詳細については、「イベントの監視」、「イベントに基づくスクリプトの実行」、「非同期イベント通知の受信」を参照してください。

' Connect to WMI, obtaining an SWbemServices object
set svc = _
CreateObject("Wbemscripting.SWbemLocator")._
   ConnectServer(,"root\cimv2")

' Obtain an SWbemEventSource object from the 
' SWbemServices.ExecNotificationQuery method to specify the 
' event source as "Application" events in a Win32_NTLogEvent
set evtsrc = svc.ExecNotificationQuery("SELECT * " _
   & "FROM __InstanceCreationEvent " _
   & "WHERE TargetInstance ISA 'Win32_NTLogEvent'" _
   & "AND TargetInstance.Logfile ='Application'")

' Wait for an event by executing the NextEvent method on the 
' SWbemEventSource object.
while (num < 5)
    set inst = evtsrc.NextEvent(-1)
    Wscript.echo inst.TargetInstance.Logfile
    num = num + 1
wend

要件

要件
サポートされている最小のクライアント
Windows Vista
サポートされている最小のサーバー
Windows Server 2008
Header
Wbemdisp.h
タイプ ライブラリ
Wbemdisp.tlb
[DLL]
Wbemdisp.dll
CLSID
CLSID_SWbemEventSource
IID
IID_ISWbemEventSource

関連項目

スクリプト API オブジェクト