Dynamic VBS printer mapping

VBscript that reads the users info property in AD for a list of printers to map.

On error resume next
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
set oUser = GetObject("LDAP://CN=" & WshNetwork.username & ",OU=Users,DC=Domain,DC=Local")
Printers=split(oUser.Get("info"),VbCrLf)
first=True
For i = LBound(Printers) to UBound(Printers)
  If first = True Then
   WshNetwork.AddWindowsPrinterConnection(trim(Printers(i)))
   WshNetwork.SetDefaultPrinter(trim(Printers(i)))
   first=False
  Else
   WshNetwork.AddWindowsPrinterConnection(trim(Printers(i)))
  End If
Next

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.