Richard Parmiter

Virtualisation blog and Knowledge Base

  • You are here: 
  • Home
  • list

MFCOM script to export the current users of an application

Posted on April 27th, 2009

Sometimes is is necessary to have a list of users in a text file of which other scripts can be run. In this case I wanted a list of all users currently logged into a specific Citrix application in order to perform some other task.

The following MFCOM script will export all the users currently logged into a specified application and export them to a text file.

Set objFarm = CreateObject(“MetaFrameCOM.MetaFrameFarm”)

Dim ObjFSO, Objuserlist
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set Objuserlist = objFSO.OpenTextFile(“c:\windows\temp\userlist.log”, 8, True)

objFarm.Initialize(1)

For Each objSession In objfarm.Sessions

if objsession.appname = (“My Application Name”) then
objuserlist.WriteLine(objSession.UserName)
End IF
Next

WScript.Echo “userlist created here – c:\windows\temp\userlist.log”

Substitute “My Application name” and the log file location as appropriate.

Save this as a .vbs file and run.

Tags: , , , , , , ,
Filed under Scripts/Reg | 1 Comment »