porkchopexpress
IS-IT--Management
We have a few new HP Linux based thin clients and i'm trying to mod our logon script so it will use the clientname variable but i can't quite seem to get it to work. Does anyone here have vb and citrix knowledge that can help?
The script works just fine from a windows client but when logging onto the citrix box it's not picking up the printers.
Using Citrix 4.5 on 2003 with HP T5735 Debian 4 clients.
The part commented "'Citrix specific section" is where i 'think' the problem lies.
Thanks.
The script works just fine from a windows client but when logging onto the citrix box it's not picking up the printers.
Using Citrix 4.5 on 2003 with HP T5735 Debian 4 clients.
The part commented "'Citrix specific section" is where i 'think' the problem lies.
Thanks.
Code:
On error resume next
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Network, computerName, room, WSHPrinters, LOOP_COUNTER, Path
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
Set WSHNetwork = CreateObject("WScript.Network")
Set Network = CreateObject("Wscript.Network")
computerName = LCase(WshNetwork.ComputerName)
room = left(computerName,3)
'-------------------------------------------------------------
'-------------------------------------------------------------
'Remove ALL old printers
'Enumerate all printers first, after that you can select the printers you want by performing some string checks
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'To remove only networked printers use this If Statement
If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
End If
'To remove all printers incuding LOCAL printers use this statement and comment out the If Statement above
'WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
Next
'Give the PC time to disconnect old printers, wait 3000 milliseconds
wscript.sleep 3000
'Set local printer to default
'------------------------------------------------------------
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'Find local printers
If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) <> "\\" Then
WSHNetwork.SetDefaultPrinter _
(WSHPrinters.Item(LOOP_COUNTER +1))
End If
Next
'------------------------------------------------------------
'Citrix specific section
if (Left(computerName, 4) = "zeus") then
computerName = LCase(WshShell.ExpandEnvironmentStrings("%CLIENTNAME%"))
end if
'------------------------------------------------------------
'Begin install new printrs by machine name
'--------------------------------------------
Select Case room
Case "ad2"
Network.AddwindowsPrinterConnection "\\trigger\AD2_4100n"
Network.SetDefaultPrinter "\\trigger\AD2_4100n"
Case "lib"
Network.AddwindowsPrinterConnection "\\trigger\Ricohafi"
Network.AddwindowsPrinterConnection "\\LIBOFF-001\DELL"
Network.AddwindowsPrinterConnection "\\trigger\LRClaser"
Network.SetDefaultPrinter "\\trigger\LRCLaser"
Case "lrc"
Network.AddwindowsPrinterConnection "\\trigger\lrclaser"
Network.SetDefaultPrinter "\\trigger\lrcLaser"
case else
End Select
'Clean Up Memory Used
set WSHNetwork = Nothing
set UserObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
Set Network = Nothing
'Quit the Script
wscript.quit