Jump to content
Sign in to follow this  
pintas

WMI ExecQuery PrintJob

Recommended Posts

I've started playing with Scriptomatic to understand a bit more of WMi Classes and how to use them. My focus is to make a print logger/counter script.

So basically i use the script below and print some pages. But when i do, the TotalPages value is always wrong. I've searched the forum to see if i could find a way to correct this, but without luck...

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")

While 1
    $AllPrintJobs = $objWMIService.ExecQuery ("SELECT * FROM Win32_PrintJob")

    For $PrintJob In $AllPrintJobs
        ConsoleWrite($PrintJob.TotalPages & @CRLF)
    Next
    Sleep(500)
WEnd

Any idea how to monitor printed pages in real time and count them?

Thanks!

Edited by pintas

Share this post


Link to post
Share on other sites
4 hours ago, pintas said:

But when i do, the TotalPages value is always wrong.

Without any details as to what is wrong with the TotalPages property's value, the quoted statement above is almost totally useless in terms of trying to get help trouble shooting your issue.  Does the TotalPages value always show zero?  Does it always show a few pages more than expected?  Does it always show a few pages less than expected?  What, specifically, is "always wrong" with the TotalPages value?

In case you weren't aware, you can read more about the Win32_PrintJob class class HERE.  If the issue with the value is that it is zero when you think it shouldn't be, then as it says on the page that I referenced, "This value may be 0 (zero) if the print job does not contain page-delimiting information.".  If that isn't the issue, then you need to provide more details.

Share this post


Link to post
Share on other sites
16 hours ago, TheXman said:

Without any details as to what is wrong with the TotalPages property's value, the quoted statement above is almost totally useless in terms of trying to get help trouble shooting your issue.  Does the TotalPages value always show zero?  Does it always show a few pages more than expected?  Does it always show a few pages less than expected?  What, specifically, is "always wrong" with the TotalPages value?

In case you weren't aware, you can read more about the Win32_PrintJob class class HERE.  If the issue with the value is that it is zero when you think it shouldn't be, then as it says on the page that I referenced, "This value may be 0 (zero) if the print job does not contain page-delimiting information.".  If that isn't the issue, then you need to provide more details.

Always wrong meaning it shows zero sometimes when i print one or more copies, or it shows 1 sometimes when i print more than one copies. It never shows the correct number of printed paper sheets. Hence... always wrong.

What does it mean to 'contain page-delimiting information'? If i print something on notepad, does that contain page-delimiting info? Is there another way to monitor printed copies?

Edited by pintas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...