+ Post New Thread
Results 1 to 2 of 2
Thin Client and Virtual Machines Thread, Map terminal session printers dependent on IP address in Technical; Until recently we've been using the following script to connect our thin clients to the correct printers and it's been ...
  1. #1
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    16

    Map terminal session printers dependent on IP address

    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:
    Code:
    ' 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?

  2. #2
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    16
    Not needed anymore, I've worked out how to change the new thinclient names.

SHARE:
+ Post New Thread

Similar Threads

  1. Ghostcast session keeps timing out ???
    By jamin100 in forum O/S Deployment
    Replies: 23
    Last Post: 26th August 2011, 09:53 PM
  2. Terminal server logon script for printers
    By cookie_monster in forum Scripts
    Replies: 11
    Last Post: 13th August 2008, 11:46 AM
  3. [CLOSED] Bug/Error: Session time out?
    By ITWombat in forum EduGeek.net Site Problems
    Replies: 1
    Last Post: 27th February 2008, 02:12 PM
  4. Replies: 4
    Last Post: 29th April 2007, 01:16 PM
  5. web page to map printers
    By markw in forum Web Development
    Replies: 9
    Last Post: 9th June 2006, 07:59 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •