The first question is - are you running "xd4ClientName.exe" before you run the Kix login script? This might be one of those situations where you need to call the login script as a Batch file - the bat file would contain something like
 Code:
@Echo Off
Rem - set the XDCLIENTNAME environment var
XD4ClientName.exe
Rem - Run the Kix login script
kix32.exe kixtart.kix
This will insure that the environment var is defined and present when Kix runs. If you run the XD4ClientName.exe from within Kix, it will set the value in the child shell, which will then die when the command ends.

Running the command on a non-Xen system causes a 4-second delay before the app dies and does NOT set the variable. Thus, if this small delay is acceptable, you could modify your Kix script like this using the above bat file:
 Code:
; Get the computer name - either remote client or local PC as appropriate
$ComputerPrt = IIf(%XDClientName%,%XDCLientName%,@WKSTA)
; Trim to firtst six chars
$ComputerPrt = Left($ComputerPrt, 6)
The rest of your code remains the same. The process I have illustrated is done in 2 steps because IIF is picky about what you place in the args. It's also easier to follow the logic. Basically, if the environment var isn't empty, use that value for the computer name, otherwise get the name from the @WKSTA macro. Trim it to the first 6 chars and process as usual.

If the delay isn't acceptable (and it's better practice anyway), modify the batch file that launches the login script to detect if this is a Xen session and run the XD4ClientName.exe command only when on a Xen server. No changes to the Kix script are necessary since the environment var won't be set either way. I'm not in the office so I can't test the Xen server detection part.. someone else here may be able to help before I can test it further.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D