If Not @LOGONMODE
Break on
EndIf
If SessionType() = "Remote desktop session"
$rc = AddPrinterConnection("\\server\printer")
;If you want the printer to become the default printer uncomment the line below
;$rc = Setdefaultprinter("\\server\printer")
EndIf
;========BELOW IS A USER DEFINED FUNCTION AKA UDF========
;========THE CODE BELOW IS READY FOR USE========
;
;Function SessionType()
;
;Contributors:
; Inspired by
; http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=195460
;
;Action:
; Gets the session type of the current user.
;
;Syntax:
; SessionType()
;
;Version:
; 1.0 August 20th 2009.
; Initial post.
;
;Parameters:
; None.
;
;Returns:
; String value holding the session type.
; Currently supports Console, RDP and ICA.
;
;Dependencies
; No known dependencies
;
;KiXtart:
; Developed and tested KiXtart 4.60 and Windows Vista Business SP2.
;
;Example(s):
; Break on
; $rc = SessionType()
; $rc
; Sleep 5
;
;Code:
Function SessionType()
Dim $sessionname, $session
$sessionname = ExpandEnvironmentVars(%sessionname%)
$session = Left($sessionname, 3)
Select
Case $Session = "Con"
$sessiontype = "Console session"
Case $session = "RDP"
$sessiontype = "Remote desktop session"
Case $session = "ICA"
$sessiontype = "Citrix ICA session"
Case 1
$sessiontype = "Unknown session type"
EndSelect
EndFunction