Page 1 of 1 1
Topic Options
#82009 - 2003-02-14 04:34 PM Citrix and/or Terminal Server Client Collection
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Citrix and/or Terminal Server Client Collection

First off, I would like to explain...
In the case of thin (Citrix or Terminal Server) clients, KiX always runs in the memory space of the server so all the standard queries and macros report on the server and not on the client. One generally does not want a logon script to run on a Terminal Server so there needs to be a method to determine and subvert the script.

Perhaps the simplest is to just check for any server and abort, assuming that one does not want their script to run on any server whatsoever. This can be done by reading the ProductType out of the registry.

Code:
;  - check if logon to Wintendo or WinNT
; @InWin - 1 = Windows NT; 2 = Windows 9x
; - check if logon to Server or Workstation
; PRODUCTTYPE - WinNT = Workstation, ServerNT = Member Server, LanmanNT = Domain Controller
;
IF @InWin = 1 ;Not Wintendo
$PRODUCTTYPE = READVALUE("HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS","PRODUCTTYPE")
; if not Workstation, just exit without notice
if $PRODUCTTYPE <> "WinNT"
Exit 1
ENDIF
ENDIF


Alternately, if the broad brush approach won't do...

How to determine that KiX is running on a Terminal Server
KiX has the @ProductSuite macro that returns the bitwise sum of the following possible Values:
00000000001 - 1 "Small Business"
00000000010 - 2 "Enterprise"
00000000100 - 4 "BackOffice"
00000001000 - 8 "CommunicationServer"
00000010000 - 16 "Terminal Server"
00000100000 - 32 "Small Business (Restricted)"
00001000000 - 64 "Embedded NT"
00010000000 - 128 "DataCenter"
00100000000 - 256 "Single User Terminal Server"
01000000000 - 512 "Home Edition"
10000000000 - 1024 "Blade Server"

If you don't understand binary math then shame on you - go back to computers 101 - do not pass GO.

So then, a Windows 2000 Advanced Server with Terminal Services in 'Application' mode should return the value '18' which is the sum of:
2 "Enterprise"
16 "Terminal Server"

Windows 2000 Server (not Advanced) with Terminal Services in 'Remote Administration' mode should return the value '272' which is the sum of:
16 "Terminal Server"
256 "Single User Terminal Server"

A Windows XP Pro with Remote Desktop enabled should return the value '256' since it doesn't match any of the other bits.

@ProductSuite was first released in KiX 4.00 but it inadvertently returned a string VarType. Many people played with it and gave up on it (myself included) when they could not get the bitwise AND '&' to work. The smarter ones did figure it out and converted the VarType with Val(). I am not too embarassed to admit that I was not one of the smart ones, only recently discovering it. Ruud has now changed @ProductSuite in 4.20 to return an integer.

So then, in a nutshell:
Code:
If Val(@ProductSuite) & 16
"It is a Terminal Server in 'Application' or 'Remote Administration' mode" ?
EndIf


or Howard's UDF:
Code:
Function ProductSuite ($Product)
Dim $Product

select
case $Product = "None" $x=0
case $Product = "Small Business" $x=1
case $Product = "Enterprise" $x=2
case $Product = "BackOffice" $x=4
case $Product = "CommunicationServer" $x=8
case $Product = "Terminal Server" $x=16
case $Product = "Small Business (Restricted)" $x=32
case $Product = "Embedded NT" $x=64
case $Product = "DataCenter" $x=128
case $Product = "Single User Terminal Server" $x=256
case $Product = "Home Edition" $x=512
case $Product = "Blade Server" $x=1024
case 1 $RC=MessageBox ("Invalid parameter used in function ProductSuite ($Product)",48)
WriteLog("Invalid parameter used in function ProductSuite ($Product)")
endselect

$ProductSuite = $x & val(@ProductSuite)
Endfunction

if ProductSuite("Terminal Server") and not ProductSuite("Single User Terminal Server")
CallScript("$HomeDrive\CitrixMap.kix")
endif



Edited by Les (2006-03-24 07:13 PM)

Top
#82010 - 2003-02-14 10:19 PM Re: Citrix and/or Terminal Server Client Collection
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Getting Client Details

There is often a need to get specific information from the thin client that is logging on to a Terminal Server. To that end, there are several environment variables that are available.

While in a Terminal Server session, spark up a DOS box and enter the command SET. Some of the vars of interest are:

%CLIENTNAME% - This is the thin client's NetBIOS name.

%SESSIONNAME% - This would be 'CONSOLE' if logged on at the console or something like 'ICA-tcp#16' if via an ICA session.

The remaining environment vars are your standard NT vars, non-specific to Terminal Services.

If you require additional information then that will require some helper apps or DLL libraries. This I will cover in the next post.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#82011 - 2003-02-14 11:04 PM Re: Citrix and/or Terminal Server Client Collection
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Helper Apps and Libraries

There have been several helper apps and libraries written to facilitate the extraction of more client details. Two of them are written with the Citrix SDK and therefore require Citrix. You need to delve into them to determine what is best for your need.

WTSManager.dll does not require Citrix but does require that the DLL be registered.

Win32Admin.DLL provides a COM interface to many useful Win32 commands not available in KiXtart.

Documentation accompanies the apps and libraries.

The following links are where you can find these helpers.

http://kentldyer.com/index.htm
wtsmanager.zip from KiXhelp.com
http://home.comcast.net/~habullock/kix_solutions.htm


Edited by NTDOC (2007-07-30 03:20 AM)

Top
#82012 - 2006-11-03 04:25 AM Re: Citrix and/or Terminal Server Client Collection
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Since the above FAQ was written, Ruud has added the @TSSession macro but it does not do anything better than what is already mentioned.
Top
Page 1 of 1 1


Moderator:  Jochen, Radimus, Glenn Barnas, Allen, Arend_, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 700 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.052 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org