?
Solved

How can I monitor print jobs for a printer?

Posted on 2008-11-20
6
Medium Priority
?
7,791 Views
Last Modified: 2012-05-05
I am currently researching to develop an application that that monitors print jobs queueing to a particular printer, coming from various workstations, each having a different user.  I need to monitor the userid of every user sending print jobs to the printer as well as the number of pages being sent.

Any help with pointing me at the right direction for a good start is appreciated.

Thanks
0
Comment
Question by:b0rnslipy
  • 3
4 Comments
 
LVL 1

Expert Comment

by:Trefrobbert
ID: 23150586
well printer usually have a good support for snmp, so I think you have to work in that direction.
have a look at this post
http://blog.crowe.co.nz/archive/2005/08/08/182.aspx
0
 
LVL 6

Expert Comment

by:activephoto
ID: 23438515
I would recommend to go down another path and use WMI to subscribe to events, then you will get information about printjobs including UserID, document name, pages printed, total pages, size etc. I am developing an application like that as well that can be running remotely.
You should use something called System.Management.ManagementEventWatcher where you define a query that will subscribe to any event regarding a printjob Create, Modify, delete. A query could look like this
SELECT * FROM __InstanceOperationEvent WITHIN 0.5 WHERE TargetInstance ISA "Win32_PrintJob"
There are different things you can subscribe to and whats interesting to use here is
__InstanceCreateEvent  (When a printjob is created)
__InstanceModifiedEvent (When a printjob changes)
__InstanceDeletionEvent (When a printjob is deleted/removed)
__InstanceOperationEvent (includes all three above and you have to look what type it is)
These WMI queries can be used to get event triggers for at least all Win32_ classes in CimV2, that includes, Processes, printers etc.



Look at these webpages for more info about the WMI usage
__InstanceCreateEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394649(VS.85).aspx
 
__InstanceModifiedEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394651(VS.85).aspx

__InstanceDeletionEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394650(VS.85).aspx
__InstanceOperationEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394652(VS.85).aspx

WMI Classes (Win32)
http://msdn.microsoft.com/en-us/library/aa394084(VS.85).aspx
System.Management.ManagementEventWatcher (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/system.management.managementeventwatcher(VS.80).aspx
Below is a code snippet of how to use the ManagementEventWatcher, it is just an excerpt from my code so its not complete, but I hope you get a point of how to use it.
Good luck!
/ Mikael

// Declaration
mWatcher = new ManagementEventWatcher(); 
mWatcher.Scope = new ManagementScope("\\\\" + strComputerName + "\\root\\CIMV2"); 
// you can play around with the WITHIN interval but it costs performance if using faster intervals
string oQuery = "SELECT * FROM __InstanceOperationEvent WITHIN 0.1 WHERE TargetInstance ISA \"Win32_PrintJob\""; 
mWatcher.Query = new EventQuery(oQuery); 
mWatcher.EventArrived += new EventArrivedEventHandler(mWatcher_EventArrived); 
mWatcher.Stopped += new StoppedEventHandler(mWatcher_Stopped); 

Open in new window

0
 
LVL 6

Accepted Solution

by:
activephoto earned 2000 total points
ID: 23438537
Forgot to tell that the computername in this case is the printserver where the printqueues are installed (not the clients printing)
/ Mikael
0
 
LVL 6

Expert Comment

by:activephoto
ID: 23648729
The solution I have suggested (last post before admin post) provides exacly the functionality that the author asked for,  also provided a code example, so its a sad that the the effort taken is left  unnoticed.
br
/ Mikael
 
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question