Citrix: Return the VIrtual IP address of the current users Citrix session

For a long time I have been trying to find or write a vbs script that will return the Virtual IP address of the current users Citrix XenApp session on Windows 2003.

I have managed to finally find a way of doing it, please comment if you have a better way!!!!!!

The big problem with the script is the user running the script needs to be a Citrix administrator.

I will continue to work on this problem and will post new versions.

CODE:

' --------------------------------------------------------
' Get a Citrux Users Virtual IP version 0.2
'
' Author: Phil Eddies
' https://geekshangout.com
'
' Disclainer:
' Use of this script / software is entirely at your own risk no support, warranty
' or guaranty is given.
'
' The author or GeeksHangout.com take not responsibility for any damage or problems
' caused by this script / software.
'
' Copyright 2007 Philip Eddies
'
' Licensed under GPL
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.'
'
'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.'
'
'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'
' --------------------------------------------------------

 
on error resume next
Const MetaFrameWinFarmObject = 1
Const MetaFrameWinSrvObject = 6
Const Active=1
Const Connected=2
 
Dim TheFarm, TheSession, TheSession2
Dim sessionID, strComputerName
SessionID = -1
 
'-------------------------
' Get the server anme
'-------------------------
Set objWSHNet = CreateObject("WScript.Network")
strServerName = objWSHNet.ComputerName
 
'-------------------------------------
' Get details of the current session
'-------------------------------------
Set TheFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
theFarm.Initialize(MetaFrameWinFarmObject)
Set TheSession = theFarm.GetSession(MetaFrameWinSrvObject, strServerName, SessionID)
strSessionID = TheSession.SessionID
strSessionName = TheSession.SessionName
 
Set TheSession2 = CreateObject("MetaFrameCOM.MetaFrameSession")
TheSession2.Initialize MetaFrameWinSrvObject, strServerName, strSessionName, strSessionID
strClientName = TheSession2.ClientName
strClientAddress = TheSession2.ClientAddress
strSessionName = TheSession2.SessionName
strVIPAddress = TheSession2.VIPAddress
 
wscript.echo "Your Virtual IP is: " & strVIPAddress

 

2 thoughts on “Citrix: Return the VIrtual IP address of the current users Citrix session”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.