Pausing Print Jobs

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

On occasion, you might need to pause a print job or set of print jobs and then resume printing those documents later. For example, if you have one document that needs to be printed immediately, you can pause all the other print jobs on a printer. As soon as that document begins to print, you can resume the paused print jobs.

Alternatively, you might have a very large document that takes a long time to print. In that case, you can pause the large document and wait until the print queue is empty before printing it.

In practice, you can pause only print jobs that are waiting in the queue. Although you can pause the document currently being printed, this usually has no practical benefit. Except for extremely large documents, the entire print job is sent to the printer buffer. Because the printer continues printing until the buffer is empty, the pause command might have no effect. If the entire print job is in the buffer, the entire print job will print. If you pause all the print jobs in the queue, those jobs will not print. However, any new documents sent to the printer will print as expected.

You can pause print jobs by using the Pause method of the IADsPrintJobOperations interface.

Note

  • The Pause method is best used for pausing only those documents in the queue that meet a specified condition. If you want to pause all the print jobs on a specific printer, you can pause the printer rather than pausing each individual print job. For more information, see "Pausing Printers" earlier in this chapter.

Scripting Steps

Listing 13.14 contains a script that pauses all the print jobs in a print queue that are over 400,000 bytes in size. 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 set the value of 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, check to see whether the size of the document being printed is greater than 400,000 bytes.
  4. For each print job larger than 400,000 bytes, use the Pause method to pause the job.

Listing 13.14   Pausing Print Jobs

1 2 3 4 5 6 7 
Set objPrinter = GetObject("WinNT://atl-ps-01/ArtDepartmentPrinter") Set colPrintJobs = objPrinter.PrintJobs For Each objPrintJob in colPrintJobs     If objPrintJob.Size > 400000 Then         objPrintJob.Pause     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