WMI Win32_PrintJob and windows service

G

Guest

Hi,
I have a windows service in C# (.NET framework 1.1) running on Windows XP
PRO SP2. This service essentiallt starts a printjob watcher. Please see the
code
snippet below.

queryInterval = ((SchedulerData)obj).Interval/­1000;
//queryInterval=1;
this.printEventWatcher = new System.Management.ManagementEv­entWatcher();
this.printEventWatcher.Query = new System.Management.EventQuery("­SELECT *
FROM __InstanceCreationEvent WITHIN "+queryInterval+" WHERE TargetInstance
ISA \"Win32_PrintJob\"");
string hostName = Dns.GetHostName();
this.printEventWatcher.Scope = new
System.Management.ManagementSc­ope("\\\\"+hostName+"\\root\\C­IMV2");
printEventWatcher.EventArrived­+=new EventArrivedEventHandler(this.­Arrived);
printEventWatcher.Start();

This service fires the EventArrived event when running as my login account.
i.e When the service is run as MaxBici and I login as MaxBici and print
documents, I see the events being fired.

But, when the service is run as NT AUTHORITY\SYSTEM (Local System account),
and I login as MaxBici and print documents the EventArrived event is not
fired.

The query interval was set to 1 second in both the above cases.

Could anyone help me with this?
What does the scope in the event watcher signify?
Isn't the data in the WMI tables visible to all users in a PC?

Thanks in advance.
Max
 

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

Top