That's the script i'm running:

 Code:
Break on

If SessionType() = "CtxMtHost"
	;User is in an ICA session.

	;Get session number
	$session = GetSessionID()
	;Get client name
	$client = ExpandEnvironmentVars(%clientname%)
	;Set printer name
	$printer = "Citrix UNIVERSAL Printer (from " + $client +") in session " + $session
	;Set default printer
	$rc = SetDefaultPrinter($printer)
	;Check for errors
	If $rc <> 0
		? "There was an error."
		? @ERROR
		? @SERROR
	Else
		? "All is ok"
		? @ERROR
		? @SERROR
	EndIf
	Sleep 5	
	
EndIf

;FUNCTION      GetSessionID()
; 
;ACTION        Returns the Terminal Server session id 
; 
;AUTHOR        pearly 
; 
;CONTRIBUTORS  Richard H. (I'm almost reluctant to claiming this function as my own.  Thank you!) 
; 
;VERSION       1.0 
; 
;DATE CREATED  2005/03/06 
; 
;DATE MODIFIED 2005/03/06 
; 
;KIXTART       KiXtart 4.20 
; 
;SYNTAX        GetSession() 
; 
;PARAMETERS    None. 
; 
;RETURNS       Integer. 
; 
;REMARKS       Uses %TEMP% environment variable. 
; 
;DEPENDENCIES  None. 
; 
;EXAMPLE       Dim $session 
;			   $session = GetSessionID() 
; 
;KIXTART BBS    
; 
Function GetSessionID()
	Dim $s_sessionid
	Dim $iIndex
	$GetSessionID = 0
	$s_sessionid = SubStr(%TEMP%, 1 + InStrRev(%TEMP%, "\"))
	While $s_sessionid <> ""
		$iIndex = InStr("0123456789ABCDEF", Left($s_sessionid, 1))
		If $iIndex
			$GetSessionID = $GetSessionID * 16 + (CInt($iIndex - 1))
			$s_sessionid = SubStr($s_sessionid, 2)
		Else
			$GetSessionID = 0
			$s_sessionid = ""
		EndIf
	Loop
EndFunction