Local Group member adds a printer to computer Diamond on Domain 2 in Active Directory
'This script assumes that the drivers for the printer are already installed on the target machine on which the printer is to be added
Dim Cont As
IADsCon
Dim ps2 As IPrintServer2
'To Add printer of model "Apple LaserWriter Plus v42.2" named
"Apple1" on port "LPT2:" on Print Server is machine "DIAMOND" in
domain "DOMAIN2"
'"server = DMSServer1" specifies that Computer named " DMSServer1"
has DMS server installed on it.
Set Cont = GetObject("NTDSloc://DOMAIN2/DIAMOND/server=
DMSServer1")
'Bind to the computer (Print Server)
Set ps2 = Cont
'IPrintServer2 interface allows to add printer
'in the following four statements first parameter is name of
property and second parameter is the value of the
property
'Note: You will have to put these properties for LRD in
WIN2K
ps2.Put "DA_DRole_Server_Name", "DCDomain2"
'specify name of the DC for NT5 domain Domain2
ps2.Put "DA_User_Name", "Domain1\Charlie"
'Name of the User connected to the AD tree
ps2.Put "DA_Password", "pwd"
'Password of the User
ps2.Put "DA_Use_Role_Type", 2
'Specifies the AD roles
ps2.Initialize
ps2.Model = "Apple LaserWriter Plus v42.2"
'Printer model (mandatory property)
ps2.ConnectedPorts = "LPT2:"
'Port (mandatory property)
ps2.InstallPrinter "Apple1"
'Add the printer, Printer name = “Apple1”
ps2.SetInfo
'commit changes
Set ps2 = Nothing
‘release the object
Set Cont = Nothing
'release the object
See Also