Monitoring the Time Print Jobs Spend in a Print Queue

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

One way to measure how well the workload is distributed among your printers is to track the amount of time documents spend in the print queue. Users can generally expect to receive their printed output within minutes after submitting a print job. If they do not, this could be the result of a single large job monopolizing the printer or of an extremely large print queue.

To help ensure that print jobs are being printed at the expected rate, you can periodically check to see whether any documents have been in the queue longer than a baseline rate established for a particular printer. For example, you might determine that all documents sent to printer A should be printed no later than 15 minutes after they have been submitted. If documents take longer than that to print, then:

  • Users might be printing too many documents to the printer.
  • Users might be printing large documents not intended for that printer.
  • The printer might be experiencing problems.

To determine the amount of time a print job has been in the print queue, use the IADsPrintJob property TimeSubmitted. This property indicates the time the print job was sent to the printer. You can subtract the submitted time from the current time to determine how long a document has been in the print queue.

Scripting Steps

Listing 13.9 contains a script that lists print jobs that have spent 15 minutes or more in the print queue. To carry out this task, the script must perform the following steps:

  1. Use a GetObject call to bind to the printer ArtDepartmentPrinter on the print server atl-ps-01.
  2. Use the PrintJobs method to assign a value to the variable colPrintJobs.

    This variable will now contain a collection consisting of all the print jobs in the ArtDepartmentPrinter print queue.

  3. For each print job in the collection, use the DateDiff function to determine the number of minutes that the job has been in the print queue and assign this value to the variable dtmTimeInQueue.

    The DateDiff function requires the following three parameters:

    • n Used by DateDiff to indicate that the time differential should be returned in minutes.
    • objPrintJob.TimeSubmitted Date and time that the print job was submitted.
    • Now Current date and time. The difference between the current date and time and the time the print job was submitted represents the amount of time that the job has been in the print queue.
  4. If dtmTimeInQueue is greater than 15, echo a message indicating the name of the document being printed and the number of minutes that this document has been in the print queue.

Listing 13.9   Monitoring the Time Print Jobs Spend in a Print Queue

1 2 3 4 5 6 7 8 
Set objPrinter = GetObject("WinNT://atl-ps-01/ArtDepartmentPrinter") Set colPrintJobs = objPrinter.PrintJobs For Each objPrintJob in colPrintJobs     dtmTimeInQueue = DateDiff("n", objPrintJob.TimeSubmitted, Now)     If dtmTimeInQueue > 15 Then         Wscript.Echo objPrintJob.Description, dtmTimeInQueue     End If Next

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net