' Script to add network printers to workstations and thin clients ' ' Author: Ric Charlton, 07/07/04 ' Declare variables and enumerate existing printer connections Set WshShell = WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections Dim computerName computerName = LCase(WshNetwork.ComputerName) if (computerName = "svrts1") then _ computerName = LCase(WshShell.ExpandEnvironmentStrings("%CLIENTNAME%")) ' Degugging line> WScript.Echo "ComputerName variable: " & computerName ' Delete existing connections to network printers For i = 0 to oPrinters.Count - 1 Step 2 On Error Resume Next if Left(oPrinters.Item(i), 3) <> "lpt" And Left(oPrinters.Item(i), 3) <> "usb" then WshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true else WScript.Echo "No network printers found" end if Next ' Add printer connections dependant upon location Select Case (Left(computerName, 7)) Case "tablet-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-reception" End Select Select Case (Left(computerName, 5)) Case "ict1-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-1" WshNetwork.AddWindowsPrinterConnection "\\mclc1\HP5500dtn" Case "ict2-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-2" WshNetwork.AddWindowsPrinterConnection "\\mclc1\HP5500dtn" Case "mini-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-technical" WshNetwork.AddWindowsPrinterConnection "\\mclc1\HP5500dtn" End Select Select Case (Left(computerName, 4)) Case "pro-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-project" WshNetwork.AddWindowsPrinterConnection "\\mclc1\HP5500dtn" End Select Select Case (Left(computerName, 3)) Case "ds-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-digital" WshNetwork.AddWindowsPrinterConnection "\\mclc1\HP5500dtn" Case "am-" WshNetwork.AddWindowsPrinterConnection "\\mclc1\printer-hp2200-1" WshNetwork.AddWindowsPrinterConnection "\\mclc1\HP5500dtn" End Select