#209535 - 2014-10-20 09:30 AM
Setting Default Printer from partial name
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Hi all. It's been a while since i've been here. My problem is as follows:
We are testing Citrix system in our company. We had a lot of problems with the printers. Finally we mange to find a solution to our printing problems but we stumbled into another one. Once the user log in to the Citrix, a new Citrix Generic printer is created. The printer name is as follows:"Citrix Universal Generic (From TC2) in session 3". I need to make that printer a default. The problem is that the name of the printer changes from user to user depends on it's workstation name and session number. The only thing that's not changing is the beginning of the printer name "Citrix Universal Generic". Is there a way in Kix like in Windows systems that i can put something like Asterisk which will replace the changing parts of the printer name?
Thanks in advance
Edited by ddady (2014-10-20 09:30 AM)
|
Top
|
|
|
|
#209538 - 2014-10-20 10:44 AM
Re: Setting Default Printer from partial name
[Re: Mart]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Thank you Mart for the fast reply. I will check the code today and will return with results.
|
Top
|
|
|
|
#209540 - 2014-10-20 03:06 PM
Re: Setting Default Printer from partial name
[Re: ddady]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
|
Top
|
|
|
|
#209541 - 2014-10-20 03:58 PM
Re: Setting Default Printer from partial name
[Re: Allen]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Mart, i can't thank you enough. The script works like a charm. I only had to change the SessionType which is "CtxMtHost" and not "ICA". We are testing Citrix XenDesktop system.
Again, Thank you Mart and also to Allen :-)
|
Top
|
|
|
|
#209542 - 2014-10-20 04:05 PM
Re: Setting Default Printer from partial name
[Re: ddady]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Since you are using Xendesktop, would you be willing to test out another UDF, ClientName().
As far as I know this has never been tested in that environment, and it would be great to add that as something that also works.
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=207561#Post207561
|
Top
|
|
|
|
#209545 - 2014-10-21 06:42 AM
Re: Setting Default Printer from partial name
[Re: Allen]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Hi Allen,
I'll gladly test the ClientName() UDF and i will return with results.
|
Top
|
|
|
|
#209546 - 2014-10-21 07:25 AM
Re: Setting Default Printer from partial name
[Re: Mart]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Thanks. Happy to help where I can.
So CtxMtHost is what you get for XenDesktop? If so then I'll update the UDF to support that one to. Do you also have XenApp or is that the same? If you do, what does it return on XenApp?
I don't use Citrix anymore so I'm not up to speed on all the products and versions.
Hi Mart, Yes, CtxMtHost is what i get when connecting to XenDesktop. I'll just give a short brief how XenDesktop works. Actually, we have 2 Host Session servers which creates a load balancing. Users login in into Citrix with a Citrix Reciever. There are 2 options to work with XenDesktop (as far as i know): 1) RDS 2) VDI
We decided to work with RDS which is actually Citrix Remote Desktop (equivalent to Microsoft's Remote Desktop 'RDP'). The two Host Session servers are equivalent to Microsoft TS Servers.
The VDI option is very different. It creates a full virtual machine for each user. This way requires more resources and fits to users who have special requirements such as heavy duty software and etc.
As far as i know, XenApp is a server that holds apps but users not actually open a session on it in order to work with the apps. Users still connect to the Host Session servers and there (in their session)they have an area like "Apps Store" which they can choose apps to work with.
Right now i'm learning the system so i'm not a 100% familiar with it. I will be glad to add more info about it as i go.
|
Top
|
|
|
|
#209547 - 2014-10-21 08:08 AM
Re: Setting Default Printer from partial name
[Re: Allen]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
Hi Allen,
Just finished testing the function. I replaced in Mart's script: $client = ExpandEnvironmentVars(%clientname%) with .
It works like a charm :-)
|
Top
|
|
|
|
#209551 - 2014-10-21 11:00 AM
Re: Setting Default Printer from partial name
[Re: Mart]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
I get "Citrix ICA session".
Ok, I understand why. I got confused between the Process Name and the Session Name. The Session Name goes like this: "ICA-CGP#43" (the number at the end changes from user to user). The Process Name is the "CtxMtHost".
That makes me wonder how come the script still works fine?!
|
Top
|
|
|
|
#209553 - 2014-10-21 12:16 PM
Re: Setting Default Printer from partial name
[Re: Mart]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
That's the script i'm running:
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
|
Top
|
|
|
|
#209554 - 2014-10-21 03:43 PM
Re: Setting Default Printer from partial name
[Re: ddady]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Thanks for the feedback!
|
Top
|
|
|
|
#209575 - 2014-10-23 09:55 AM
Re: Setting Default Printer from partial name
[Re: Mart]
|
ddady
Getting the hang of it
Registered: 2006-09-03
Posts: 98
|
I'll try running it on debug mode and see if i can find something.
Edited by ddady (2014-10-23 09:57 AM)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|