This is the whole section of the script that maps the printers. The section above is not for the first printer, which makes it a not more confusing for me. I am not overly converse with vb but know enough to get around.
Code:
blnLocal = FALSE
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
For Each objPrinter in colPrinters
If objPrinter.Attributes And 64 Then
blnLocal = TRUE
End If
Next
If blnLocal = FALSE Then
' Variables declaration
Dim objNet, strComputerName, cmp
' Read NetBIOS computer name
Set objNet = WScript.CreateObject( "WScript.Network" )
strComputerName = objNet.ComputerName
'Remove obsolete Printers
'objNet.RemovePrinterConnection ( "\\Sun\iR5200 - Admin" ) , true, true
'objNet.RemovePrinterConnection ( "\\Sun\iR5200 - Admin" ) , true, true
' Create printers for computers in Staff Room
cmp = InStr( 1, strComputerName, "ACW-STAFF", 1)
If cmp > 0 Then
objNet.AddWindowsPrinterConnection( "\\Sun\iR5200 - Admin" )
objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Staff" )
' objNet.AddWindowsPrinterConnection( "\\Sun\T8024-Admin" )
' objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Admin" )
objNet.SetDefaultPrinter( "\\sun\HP2015n-Staff" )
WScript.Quit
End If
' Create printers for computers on Staff Laptops
cmp = InStr( 1, strComputerName, "ACW-LT", 1)
If cmp > 0 Then
' objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Lib" )
objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-214" )
objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-102" )
objNet.AddWindowsPrinterConnection( "\\Sun\iR5200 - Admin" )
objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Staff" )
' objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Admin" )
' objNet.AddWindowsPrinterConnection( "\\Sun\T8024-Admin" )
objNet.SetDefaultPrinter( "\\sun\HP2015n-Staff" )
WScript.Quit
End If
' Create printers for computers in Admin
cmp = InStr( 1, strComputerName, "ACW-ADMIN", 1)
If cmp > 0 Then
objNet.AddWindowsPrinterConnection( "\\Sun\iR5200 - Admin" )
objNet.AddWindowsPrinterConnection( "\\Sun\HP2015n-Staff" )
objNet.AddWindowsPrinterConnection( "\\Sun\T8024-Admin" )
objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Admin" )
' objNet.AddWindowsPrinterConnection( "\\sun\Ky1800-DP" )
' objNet.SetDefaultPrinter( "\\sun\HP2015n-Admin" )
WScript.Quit
End If
' Create printers for computers in Room 102
cmp = InStr( 1, strComputerName, "ACW-102", 1)
If cmp > 0 Then
objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-102" )
objNet.SetDefaultPrinter( "\\Sun\HP1200-102" )
WScript.Quit
End If
' Create printers for computers in Room 214
cmp = InStr( 1, strComputerName, "ACW-214", 1)
If cmp > 0 Then
objNet.RemovePrinterConnection ( "\\Sun\HP1200-102" ) , true, true
objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-214" )
objNet.SetDefaultPrinter( "\\Sun\HP1200-214" )
WScript.Quit
End If
' Create printers for computers in Room 215
cmp = InStr( 1, strComputerName, "ACW-215", 1)
If cmp > 0 Then
objNet.RemovePrinterConnection ( "\\Sun\HP1200-102" ) , true, true
objNet.AddWindowsPrinterConnection( "\\Sun\HP2015n-215" )
objNet.SetDefaultPrinter( "\\Sun\HP2015n-215" )
WScript.Quit
End If
' Create printers for computers in Library
cmp = InStr( 1, strComputerName, "ACW-LIB", 1)
If cmp > 0 Then
objNet.RemovePrinterConnection ( "\\Sun\HP1200-102" ) , true, true
objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Lib" )
objNet.SetDefaultPrinter( "\\sun\HP2015n-Lib" )
WScript.Quit
End If
' Create printers for computers in Bookhire
'cmp = InStr( 1, strComputerName, "ACW-Bookhire", 1)
'If cmp > 0 Then
' objNet.AddWindowsPrinterConnection( "\\Sun\Ky1800-Lib" )
' objNet.SetDefaultPrinter( "\\Sun\Ky1800-Lib" )
' WScript.Quit
'End If
' Create printers for computers in Room 211
cmp = InStr( 1, strComputerName, "ACW-211", 1)
If cmp > 0 Then
objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-214" )
objNet.SetDefaultPrinter( "\\Sun\HP1200-214" )
WScript.Quit
End If
End If