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.

;  - 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
; if not Workstation, just exit without notice
Exit 1

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:
If Val(@ProductSuite) & 16
"It is a Terminal Server in 'Application' or 'Remote Administration' mode" ?

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

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)")

$ProductSuite = $x & val(@ProductSuite)

if ProductSuite("Terminal Server") and not ProductSuite("Single User Terminal Server")

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