Configuring Print Job Properties

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

The IADsPrintJob interface can be used to configure print job properties while those print jobs are in the print queue. Typically, this is done to control the order in which documents, especially large documents that might monopolize printer time, are printed.

For example, suppose you have several large (more than 400 KB) print jobs in the print queue, along with a number of smaller print jobs. You might want the small print jobs to print first so that those users do not have to wait for the larger jobs to finish. In this scenario, you want jobs to print in this order:

  1. Any existing jobs less than 400 KB.
  2. Any existing jobs greater than 400 KB.
  3. Any new jobs added to the queue.

In this case, pausing the larger print jobs will not suffice. After all, while those jobs are paused, any new jobs added to the print queue will move ahead of them in the queue.

Instead, you can change the priority of each print job. For example, jobs less than 400 KB can be given a priority of 3. Because higher-priority jobs print first, these jobs will immediately move to the head of the print queue. Print jobs greater than 400 KB can be given a priority of 2. Any new jobs that are sent to the print queue will have the default priority of 1. As a result, they will not be printed until after the larger print jobs have finished.

You must use the WinNT provider to bind to and configure print jobs; the LDAP provider does not support the IADsPrintJob interface. This means your script has to bind to a specific printer on a specific print server using a format similar to the following:

Set objPrinter = GetObject("WinNT://printserver1/financeprinter") 

Scripting Steps

You can control the order in which a job prints in several ways. For example:

  • You can change the priority of a print job.
  • You can change the start time of a print job.

Changing the priority of a print job

Listing 13.20 contains a script that changes the priority of a print job. To carry out this task, the script must perform the following steps:

  1. Use a GetObject call to bind to the printQueue object on the print server.

    Because the LDAP provider does not support binding to print jobs, you must use the WinNT provider and bind to a specific printer on a specific print server.

  2. For each print job in the print queue, check the size of the print job. If the size is greater than 400,000 bytes, set the job priority to 2. If the job size is less than this, set the job priority to 3.

    Job priorities are set using the Put method and the following two parameters:

    • The name of the attribute to be configured (Priority).
    • The value to be assigned the attribute (either 2 or 3).
  3. After configuring the priority, use the SetInfo method to write the changes to the print job.

Listing 13.20   Changing Print Job Priority

1 2 3 4 5 6 7 8 9 10 11 
Set objPrinter = GetObject _     ("WinNT://atl-ps-01/ArtDepartmentPrinter ") For each objPrintJob in objPrinter.PrintJobs     If objPrintJob.Size > 400000 Then         objPrintJob.Put "Priority" , 2         objPrintJob.SetInfo     Else         objPrintJob.Put "Priority" , 3         objPrintJob.SetInfo     End If Next

Changing the start time of a print job

Another way to postpone the printing of large documents is to change the start time for that print job. For example, the script shown in Listing 13.21 changes the start time for all documents greater than 400,000 bytes to 2:00 A.M. To carry out this task, the script must perform the following steps:

  1. Use a GetObject call to bind to the printQueue object on the print server.

    Because the LDAP provider does not support binding to print jobs, you must use the WinNT provider and bind to a specific printer on a specific print server.

  2. For each print job in the print queue, check the size of the print job. If the size is greater than 400,000 bytes, set the start time to 2:00 A.M. If the job size is less than this, do nothing.

    Job priorities are set by using the Put method and the following two parameters:

    • The name of the attribute to be configured (StartTime).
    • The value to be assigned the attribute (2:00:00 AM). To ensure that the start time is passed in the correct date and time format, use the VBScript TimeValue function, which converts a string expression (such as 2:00:00 AM) to a datetime value.
  3. After configuring the start time, use the SetInfo method to write the changes to the print job.

Listing 13.21   Changing the Start Time of a Print Job

1 2 3 4 5 6 7 8 
Set objPrinter = GetObject _     ("WinNT://atl-ps-01/ArtDepartmentPrinter") For each objPrintQueue in objPrinter.PrintJobs If objPrintQueue.Size > 400000 Then     objPrintQueue.Put "StartTime" , TimeValue("2:00:00 AM")     objPrintQueue.SetInfo 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