WMIwatcher / trigger on logonsession?

  • Thread starter Thread starter arjan
  • Start date Start date
A

arjan

Hi,

I found snippets on how you can define a processwatcher. It is based on
a WMI-query with a trigger. It uses the WqlEventQuery class.

Does anyone have a code snippet for the same functionality on the
Logonsessions within WMI?
The query that the trigger should be created on is "SELECT * FROM
Win32_LogonSession".... The goal is to recieve a trigger on a logon,
witch gives me the logontime and the userID

cheers

Trumpeteer
 
| Hi,
|
| I found snippets on how you can define a processwatcher. It is based on
| a WMI-query with a trigger. It uses the WqlEventQuery class.
|
| Does anyone have a code snippet for the same functionality on the
| Logonsessions within WMI?
| The query that the trigger should be created on is "SELECT * FROM
| Win32_LogonSession".... The goal is to recieve a trigger on a logon,
| witch gives me the logontime and the userID
|
| cheers
|
| Trumpeteer
|

ManagementEventWatcher w = null;
WqlEventQuery q = new WqlEventQuery();
q.EventClassName = "__InstanceOperationEvent";
q.WithinInterval = new TimeSpan(0,0,3); // query interval
q.Condition = @"TargetInstance ISA 'Win32_LogonSession'";
w = new ManagementEventWatcher( q);
w.EventArrived += new EventArrivedEventHandler(LogonEventArrived);
w.Start();
....
....

public void LogonEventArrived(object sender, EventArrivedEventArgs e) {
//Get the Event object and display it
foreach(PropertyData pd in e.NewEvent.Properties) {

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top