Sorry, you are right.
I am working on a windows environment (my rails server is installed on a
windows 2000 machine). With my rails server I would like to get a list
of the jobs which are currently being processed in a printer (local or
network printer).
What is the best way to get this kink of information?
regards
The Win32_PrintJob WMI class will provide this information. You can
access WMI in Ruby using win32ole. Here's a link to a page with a
vbscript example.
http://www.microsoft.com/technet/scriptcenter/guide/sas_prn_owev.mspx?mfr=true
You can also use my Ruby-WMI gem, which wraps win32ole and provides an
API similar to ActiveRecord. Here are some code samples:
<code>
require 'ruby-wmi'
WMI::Win32_PrintJob.find

all).each{ |job|
job.properties_.each{ |prop|
puts "#{prop.name}: #{job[prop.name]}"
}
}
</code>
<output>
Caption: \\server\printer, 191
DataType: RAW
Description: \\server\printer, 191
Document: document.pdf
DriverName: HP LaserJet 4250 PS
ElapsedTime: 00000000000000.000000:000
HostPrintQueue: \\10.1.53.7
InstallDate:
JobId: 191
JobStatus:
Name: \\server\printer, 191
Notify: gthiesfeld
Owner: gthiesfeld
PagesPrinted: 0
Parameters:
PrintProcessor: hpzpp38Y
Priority: 1
Size: 495840
StartTime:
Status: UNKNOWN
StatusMask: 0
TimeSubmitted: 20080228111424.908000-360
TotalPages: 3
UntilTime:
</output>
This uses the properties_ method to iterate through all of the
properties and spits them out. Once you know which properties you
want to use, you can replace them, like so:
<code>
require 'ruby-wmi'
WMI::Win32_PrintJob.find

all).each{ |job|
puts "Name: #{job.name}"
puts "PagesPrinted: #{job.PagesPrinted}"
puts "TotalPages: #{job.TotalPages}"
}
</code>
<output>
Name: \\server\printer, 191
PagesPrinted: 0
TotalPages: 3
</output>
Hope that helps.
Gordon