Geoff Posted July 19, 2006 Posted July 19, 2006 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?
CyberNerd Posted July 19, 2006 Posted July 19, 2006 if 'echo %hostname%' returns the name of the Citrix server, it must be running on the terminal server
Geoff Posted July 19, 2006 Author Posted July 19, 2006 That doesn't help in a published application enviroment.
NetworkGeezer Posted July 19, 2006 Posted July 19, 2006 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.
NetworkGeezer Posted July 19, 2006 Posted July 19, 2006 Oops forgot to mention. It's ICA for MetaFrame and RDP for vanilla Windows Terminal Services
Geoff Posted July 19, 2006 Author Posted July 19, 2006 I see, therefore something like: echo %sessionname% | find /I "ICA-tcp" if %errorlevel%==0 goto (GOTO:EOF) echo %sessionname% | find /I "RDP-Tcp" if %errorlevel%==0 goto (GOTO:EOF) should do the trick then.
CyberNerd Posted July 19, 2006 Posted July 19, 2006 '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
NetworkGeezer Posted July 19, 2006 Posted July 19, 2006 @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.
CyberNerd Posted July 19, 2006 Posted July 19, 2006 @NetworkGeezer your quite right, heat has probably caused my brain to stop working correctly. My original post was wrong but I didn't realise. 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. I see what you mean, I was thinking of distinguishing between TS/RDP and non TS/RDP applications.
NetworkGeezer Posted July 19, 2006 Posted July 19, 2006 @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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now