+ Post New Thread
Results 1 to 10 of 10
Thin Client and Virtual Machines Thread, Detect Ctitrix session from within bat/vbs? in Technical; I need a way for a bat/vbs file to detect if its running from within a Citrix Metaframe session/published application ...
  1. #1

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223

    Detect Ctitrix session from within bat/vbs?

    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?

  2. #2


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    338

    Re: Detect Ctitrix session from within bat/vbs?

    if 'echo %hostname%' returns the name of the Citrix server, it must be running on the terminal server

  3. #3

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223

    Re: Detect Ctitrix session from within bat/vbs?

    That doesn't help in a published application enviroment.

  4. #4

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Detect Ctitrix session from within bat/vbs?

    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.

  5. #5

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Detect Ctitrix session from within bat/vbs?

    Oops forgot to mention.

    It's ICA for MetaFrame and RDP for vanilla Windows Terminal Services

  6. #6

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223

    Re: Detect Ctitrix session from within bat/vbs?

    I see, therefore something like:

    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)
    should do the trick then.

  7. #7


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    338

    Re: Detect Ctitrix session from within bat/vbs?

    '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

  8. #8

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Detect Ctitrix session from within bat/vbs?

    @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.

  9. #9


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    338

    Re: Detect Ctitrix session from within bat/vbs?

    @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.

  10. #10

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Detect Ctitrix session from within bat/vbs?

    @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.

SHARE:
+ Post New Thread

Similar Threads

  1. Apple Training Session
    By GrumbleDook in forum Courses and Training
    Replies: 8
    Last Post: 23rd February 2010, 09:50 PM
  2. Replies: 8
    Last Post: 22nd September 2009, 04:14 PM
  3. Automatically detect settings
    By techyphil in forum Windows
    Replies: 5
    Last Post: 26th November 2007, 09:28 PM
  4. Limit Session Duration
    By DaveP in forum Wireless Networks
    Replies: 1
    Last Post: 29th March 2007, 08:50 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •