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?

user692942
  • 16,398
  • 7
  • 76
  • 175
gumuruh
  • 2,544
  • 4
  • 33
  • 56
  • This [sample script](https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/Win7Samples/sysmgmt/wmi/scripting/wsh/vbscript/PrintJobs.Vbs) should point you in the right direction. – user692942 Dec 31 '22 at 12:49
  • 1
    the Win32_PrintJob doesn't have the "Number of Copies" part. @user692942 .... – gumuruh Dec 31 '22 at 17:55
  • Sorry mis-read the question, have you looked at the [Win32_PrinterConfiguration class](https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-printerconfiguration)? – user692942 Jan 01 '23 at 01:39
  • 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.... – gumuruh Jan 01 '23 at 09:05
  • 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. – user692942 Jan 01 '23 at 09:10
  • any clue where should i jump into for obtaining the "number of copies" from every printjob detail? .... WMI throught out VBscript quite tough nowadays.... – gumuruh Jan 01 '23 at 09:26
  • 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. – user692942 Jan 01 '23 at 13:45

1 Answers1

2

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.

Nick Westgate
  • 3,088
  • 2
  • 34
  • 41