Home > Back-end >  WMI to get current printer job (including number of copies)
WMI to get current printer job (including number of copies)

Time:01-02

I tried to follow the example of WMI scripting (VBScript) to obtain several info from the current Windows OS, including the print job. Both are working successfully.

' My SampleCapturingPrinter.vbs
' ———————————————–‘
Option Explicit
Dim objWMIService, objItem, colItems, strComputer

' On Error Resume Next
strComputer = "."

While True

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer")

For Each objItem in colItems
Wscript.Echo "- " & objItem.DefaultCopies
Next

Wscript.Echo "====================="
WScript.Sleep 1000

Wend


WSCript.Quit

' End of My SampleCapturingPrinter.vbs
' ———————————————–

But from the official documentation , there is no info about -current number of copies- ? So my question is... where is the counter located / stored exactly?

If let say the user click Print through out any app and set the copies to let say '3 copies' and pressed (Print). The printer job tracked nicely, but I don't know where the 'number of copies' stored.

CMIIW, is it possible through out WMI to obtain the current details?

CodePudding user response:

As I've said in other answers, WMI has problems with printing, and it doesn't provide copies.

The question itself is problematic, similar to N-Up. Early printers didn't have any concept of copies, so the Windows printing APIs support the concept weakly with an optional copies entry in the DEVMODE. To complicate things, some apps (notably some versions of MS Office) handle copies internally, while some drivers don't use the DEVMODE entries.

  • Related