Andi Posted September 2, 2008 Posted September 2, 2008 Until recently we've been using the following script to connect our thin clients to the correct printers and it's been working like a charm: ' Script to add network printers to workstations and thin clients ' ' Author: Ric Charlton, 07/07/04 (amended 26/08/05) ' Declare variables and enumerate existing printer connections On Error Resume Next Set WshShell = WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections Dim computerName computerName = LCase(WshNetwork.ComputerName) ' Citrix specific section if (Left(computerName, 4) = "orcs") then computerName = LCase(WshShell.ExpandEnvironmentStrings("%CLIENTNAME%")) WshNetwork.AddWindowsPrinterConnection "\\" & computerName & "\printer" ' Debug 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, 4)) Case "chap" WshNetwork.AddWindowsPrinterConnection "\\theoden\chapel1710" WshNetwork.SetDefaultPrinter "\\theoden\chapel1710" Case "newh" WshNetwork.AddWindowsPrinterConnection "\\theoden\newhouse" WshNetwork.SetDefaultPrinter "\\theoden\newhouse" Case "gran" WshNetwork.AddWindowsPrinterConnection "\\theoden\grange" WshNetwork.SetDefaultPrinter "\\theoden\grange" Case "tudh" WshNetwork.AddWindowsPrinterConnection "\\theoden\tudorhouse" WshNetwork.SetDefaultPrinter "\\theoden\tudorhouse" Case "hist" WshNetwork.AddWindowsPrinterConnection "\\theoden\histlib" WshNetwork.SetDefaultPrinter "\\theoden\histlib" Case Else ' WScript.Echo "No default printers added" End Select end if What I would like to do now though is connect to the correct printer depending on the third octet of the station IP address, eg; connect 192.168.8.* to \\servername\printer connect 192.168.7.* to \\servername\printer Is there a variable change that I can edit in the above script to get this to work?
Andi Posted September 3, 2008 Author Posted September 3, 2008 Not needed anymore, I've worked out how to change the new thinclient names.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now