I need a way for a bat/vbs file to detect if its running from within a Citrix Metaframe session/published application enviroment. Anyone know how?
I need a way for a bat/vbs file to detect if its running from within a Citrix Metaframe session/published application enviroment. Anyone know how?

if 'echo %hostname%' returns the name of the Citrix server, it must be running on the terminal server
That doesn't help in a published application enviroment.
Look for the SESSIONNAME variable. This will either say RDP-TCP#xyz or ICA-TCP#xyz
@Cybernerd
COMPUTERNAME is the environmental variable and HOSTNAME is the command. Unfortunately you can't do `HOSTNAME` quite so easily on the Windows command line as you can in *nix.
Inany case the value is the server name will be the same under both presentation protocols.
Oops forgot to mention.
It's ICA for MetaFrame and RDP for vanilla Windows Terminal Services
I see, therefore something like:
should do the trick then.Code:echo %sessionname% | find /I "ICA-tcp" if %errorlevel%==0 goto (GOTO:EOF) echo %sessionname% | find /I "RDP-Tcp" if %errorlevel%==0 goto (GOTO:EOF)

'echo %computername%' does return the hostname, but here the command 'hostname' also returns the hostname.
How about when you publish the application, you publish the bat/vbs script that then calls the actual aplication
@Geoff
But surely you want the test to produce two different outcomes?
@Cybernerd
In your orginal post you said 'echo %HOSTNAME%'
This would produce nothing as HOSTNAME is not a defined variable but the name of command which produces the same result as echo %COMPUTERNAME%
Anyway it would an ineffective test as Citrix now runs on top of Windows 200x Terminal Serices so COMPUTERNAME/HOSTNAME wouldn't be able to distingusih between an RDP or ICA/Metframe session.

@NetworkGeezer your quite right, heat has probably caused my brain to stop working correctly. My original post was wrong but I didn't realise.
[quote]Anyway it would an ineffective test as Citrix now runs on top of Windows 200x Terminal Serices so COMPUTERNAME/HOSTNAME wouldn't be able to distingusih between an RDP or ICA/Metframe session.[quote]
I see what you mean, I was thinking of distinguishing between TS/RDP and non TS/RDP applications.
@CyberNerd: No worries m8. It happens to the best of us at one time or another
@ 1 and all:
Another difference between ICA and RDP is that for an ICA session the CLIENTNAME variable returns the name defined in the WFCNAME.INI file on the client PC where as RDP returns the actual host name as reported by host OS on the client PC.
This means you can change client names in ICA without having to do anything in Active Directory.
There are currently 1 users browsing this thread. (0 members and 1 guests)