471,598 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,598 software developers and data experts.

WMIwatcher / trigger on logonsession?

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

Feb 20 '06 #1
2 3210

<ar***@kauffman.tk> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
| 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.
Feb 20 '06 #2
great!

Thanks a million!

Feb 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Matik | last post: by
6 posts views Thread by Scott CM | last post: by
9 posts views Thread by Martin | last post: by
reply views Thread by JohnO | last post: by
7 posts views Thread by Shane | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.