WMI to get current printer job (including number of copies) [duplicate]
Asked Answered
G

1

1

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?

Glycerite answered 31/12, 2022 at 4:8 Comment(7)
This sample script should point you in the right direction.Sur
the Win32_PrintJob doesn't have the "Number of Copies" part. @Sur ....Glycerite
Sorry mis-read the question, have you looked at the Win32_PrinterConfiguration class?Sur
You are right... @user692942... there is a 'Number of copies' part over there. But i wonder is this applied to every print jobs call... or it's as default device copy's configuration? Let's try first....Glycerite
It doesn’t look as though the number of copies is stored as a per print job value judging by the structure of the classes which does seem strange.Sur
any clue where should i jump into for obtaining the "number of copies" from every printjob detail? .... WMI throught out VBscript quite tough nowadays....Glycerite
Like i’ve already said, it doesn’t seem as it is stored per print job but you can get it from the Win32_PrinterConfiguration class, so experiment with that and see what the results are like.Sur
H
3

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.

Hurtle answered 2/1, 2023 at 2:18 Comment(2)
very sad to accept about the truth that WMI is unable to get that number (of copies). :'( Thanks @NickWestgateGlycerite
@gumuruh: Yes, unfortunately WMI just echoes the fact that Windows' print APIs are a mess.Hurtle

© 2022 - 2025 — McMap. All rights reserved.