' Script to add network printers to workstations and thin clients ' ' Author: Ric Charlton, 07/07/04 SleepTime=30 ' Declare variables and enumerate existing printer connections Set WshShell = WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections dim ofs set ofs = wscript.createobject("scripting.filesystemobject") Dim computerName computerName = LCase(WshNetwork.ComputerName) ' 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 msgbox "Location = " & Left(computerName, 3) Select Case (Left(computerName, 3)) Case "lrc" WshNetwork.AddWindowsPrinterConnection "\\titanium\lrc_richap2700" Case "ali" WshNetwork.AddWindowsPrinterConnection "\\titanium\lrc_richap2700" Case "lib" WshNetwork.AddWindowsPrinterConnection "\\titanium\lrc_richap2700" Case "w4-" WshNetwork.AddWindowsPrinterConnection "\\titanium\W4_Brother5170DN" Case "s1-" WshNetwork.AddWindowsPrinterConnection "\\titanium\S1_HP4200" Case "s6-" WshNetwork.AddWindowsPrinterConnection "\\titanium\S6_HP5n" Case "w13" WshNetwork.AddWindowsPrinterConnection "\\titanium\W13_HP4200" Case "w14" WshNetwork.AddWindowsPrinterConnection "\\titanium\W13_HP4200" msgbox "W14 Printer Connected" Case "f5-" WshNetwork.AddWindowsPrinterConnection "\\titanium\F5_HP4200" Case "f6-" WshNetwork.AddWindowsPrinterConnection "\\titanium\F6_Brother5170DN" Case "s8-" WshNetwork.AddWindowsPrinterConnection "\\titanium\S8_KyoceraFS-1700" Case "b4-" WshNetwork.AddWindowsPrinterConnection "\\titanium\B4_HP4200" Case "sen" WshNetwork.AddWindowsPrinterConnection "\\titanium\SEN_HP5N" Case "w6-" WshNetwork.AddWindowsPrinterConnection "\\titanium\W6_HP4100" Case "s9-" WshNetwork.AddWindowsPrinterConnection "\\titanium\S9_HP4100" Case "r1-" WshNetwork.AddWindowsPrinterConnection "\\titanium\R1_HP4200" Case "w6-" WshNetwork.AddWindowsPrinterConnection "\\titanium\W6_HP4100" Case "tec" WshNetwork.AddWindowsPrinterConnection "\\titanium\TechOffice_2550n" Case else ofs.copyfile "NoPrinter.txt", "C:\" End Select ofs.copyfile "Test01.txt", "c:\" WScript.Sleep SleepTime*1000 msgbox "Done!"