System.Management.WqlEventQuery

IfYouSaySo

Well-known member
Joined
Jan 4, 2006
Messages
102
Location
Hermosa Beach, CA
Programming Experience
3-5
I'm having problems with the following code below. The call to ServiceWatcher.Start is throwing a "Not found" exception. My googling has determined that something about my query is incorrect. I'm not sure what about it is wrong though...
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] scope [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ManagementScope([/SIZE][SIZE=2][COLOR=#800000]"\\.\root\CIMV2"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]scope.Options.EnablePrivileges = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] query [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] WqlEventQuery()[/SIZE]
[SIZE=2]query.WithinInterval = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] TimeSpan(0, 0, 1)[/SIZE]
[SIZE=2]query.EventClassName = [/SIZE][SIZE=2][COLOR=#800000]"__InstanceModificationEvent"[/COLOR][/SIZE]
[SIZE=2]query.Condition = [/SIZE][SIZE=2][COLOR=#800000]"TargetInstance ISA Win32_Service"[/COLOR][/SIZE]
[SIZE=2]ServiceWatcher = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ManagementEventWatcher(scope, query)[/SIZE]
[SIZE=2][COLOR=#0000ff]AddHandler[/COLOR][/SIZE][SIZE=2] ServiceWatcher.EventArrived, [/SIZE][SIZE=2][COLOR=#0000ff]AddressOf[/COLOR][/SIZE][SIZE=2] ServiceModificationEventHandler[/SIZE]
[SIZE=2]ServiceWatcher.Start()[/SIZE]
 
Back
Top