Manipulating Print Queues and Print Jobs
So far we’ve shown you how to use ADSI to manipulate persistent and dynamic objects, such as shares, sessions, and resources. Now we’re going to examine printer queues and jobs. In this section, we’re going to lead you through creating scripts to do the following:
Identify print queues in Active Directory
Bind to a print queue[28] and access its properties
List the print jobs in a print queue and manipulate them
Tip
All the code in these scripts for managing printers is done using the WinNT provider, so it will work on Windows NT as well as Active Directory. The LDAP searches will not work on Windows NT.
One point before we go on: at the end of Chapter 20, we detail a function called SearchAD. We need
to use it now to search Active Directory for the
printer’s ADsPath and store it in
arrSearchResults(0,0).
Identifying Print Queues in Active Directory
List-Print-Queue.vbs
in Example 22-2
is a heavily commented script, so it
should be easy to follow.
Example 22-2. List-Print-Queue.vbs identifies print queues in Active Directory
Option Explicit On Error Resume Next '********************************************************************** 'Active Directory path to start the search from '********************************************************************** Const strDomainToSearch = "LDAP://dc=mycorp,dc=com" '********************************************************************** 'Maximizes the Notepad screen when started '********************************************************************** ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access