Page 1 of 1 1
Topic Options
#160711 - 2006-04-12 11:52 AM Get Published application
krex Offline
Fresh Scripter

Registered: 2006-03-02
Posts: 39
Hi!
Could somebody help me out i want all publish application in a citrix farm and i want there location and the groups who have access to the application.
Is this a wmi script or is it a MFCOM i should use for that.

If anybody could help me getting startet or just give somekind of idea to get startet.

Top
#160712 - 2006-04-12 12:27 PM Re: Get Published application
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I've got something in KiXtart that I use to remove all apps from a farm member so that I can remove the server from the farm when everyone has disconnected. I'll dig it out for you - it's not exactly what you are asking for, but it will get you started.
Top
#160713 - 2006-04-12 12:33 PM Re: Get Published application
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here it is.
Code:
Break ON
$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")

; Initialise local variables {{{
Dim $oFarm,$oServer,$oApplication
Dim $sIni,$sBackupINI,$sApplication,$sApplicationDN,$sBackup
DIM $METAFRAMEWINAPPOBJECT

$sIni=".\PublishedApps.ini"
$sBackupIni=".\PublishedAppsHistory.ini"
$METAFRAMEWINAPPOBJECT=3
;}}}
Color w+/r+ "WARNING" Color w/n " This script will remove all published apps from this server"+@CRLF
" Enter 'Y' to continue, or any other key to exit: " Get $
If $<>"Y" Exit 0 EndIf
@CRLF

; Initialise FARM object {{{
$oFarm=CreateObject("MetaframeCOM.MetaframeFarm")
If @ERROR Or VarType($oFarm)<>9 Abort("Cannot create FARM object",@ERROR,@SERROR) EndIf
$oFarm.Initialize(1)
If @ERROR Abort("Cannot create FARM object",@ERROR,@SERROR) EndIf
; }}}

; Backup all entries for this server to the config file. {{{
$sBackup=@WKSTA+" "+@DATE+" "+@TIME
For Each $sApplication In Split(ReadProfileString($sIni,@WKSTA,""),Chr(10))
If $sApplication
$sApplicationDN=ReadProfileString($sIni,@WKSTA,$sApplication)
$=WriteProfileString($sBackupIni,$sBackup,$sApplication,$sApplicationDN)
$=WriteProfileString($sIni,@WKSTA,$sApplication,"")
EndIf
Next ;}}}

; Remove applications {{{
For Each $oServer in $oFarm.servers
If $oServer.serverName=@WKSTA
Log("Match: "+$oServer.serverName)
For Each $oApplication in $oServer.applications
Log("App: "+$oApplication.appName+" ("+$oApplication.distinguishedName+")")
$=WriteProfileString($sIni,@WKSTA,$oApplication.appName,$oApplication.distinguishedName)
If @ERROR Abort("Cannot add application to backup file",@ERROR,@SERROR) EndIf
$oApplication.LoadData(1)
If @ERROR Abort("Cannot add load application state",@ERROR,@SERROR) EndIf
$oApplication.RemoveServer(@WKSTA)
If @ERROR Abort("Cannot add remove application from server",@ERROR,@SERROR) EndIf
$oApplication.SaveData()
If @ERROR Abort("Cannot save load application state",@ERROR,@SERROR) EndIf
Next
EndIf
Next
; }}}
Exit 0

Function Log($s) ; {{{
@DATE+" "+@TIME+" "+$s+@CRLF
EndFunction ; }}}

Function Abort($s,$iError,$sError) ; {{{
Log($s+IIF($iError="",""," ["+$iError+"]")+IIF($iError="",""," "+$sError))
Exit CInt($iError)
EndFunction ; }}}
; vim600:ts=4 sw=4 ai fdc=4 fdm=marker


Top
#160714 - 2006-04-12 02:58 PM Re: Get Published application
krex Offline
Fresh Scripter

Registered: 2006-03-02
Posts: 39
Hi!
This is almost working the only thing that i am missing is the commandline of the applications´. As i see it in MFCOM i need to get in contact with WinAppObject to get the Commandline. to fit in my script below it should be something like:

$ctxApp.WinAppObject
? "Workdir is - " +$ctxApp.DefaultInitProg

Now WinAppObject is a pointer how is pointer in kix.....?
Is pointer not supportet or is there a work around...?
Will pointer be supportet in kix in like.... Next week...?

$ctxfarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
$ctxfarm.Initialize(1)
For Each $ctxApp In $ctxfarm.Applications
? "Published Application - " + $ctxApp.Appname
For Each $AppGrp In $ctxApp.Groups
? "Groups - "+ $AppGrp.GroupName
Next
Next
get $

Top
#160715 - 2006-04-12 04:06 PM Re: Get Published application
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try this, it works for me:
Code:
Break ON
$TRUE=NOT 0
$FALSE=NOT $TRUE

$MetaFrameWinFarmObject=1
$MetaFrameWinAppObject=3

$oFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
If @ERROR "ERROR: Cannot create farm object ["+@ERROR+"] "+@SERROR+@CRLF Exit @ERROR EndIf
$oFarm.Initialize($MetaFrameWinFarmObject)
If @ERROR "ERROR: Cannot initialise farm object ["+@ERROR+"] "+@SERROR+@CRLF Exit @ERROR EndIf

If Not $oFarm.WinFarmObject.IsCitrixAdministrator
"You must be a Citrix admin to run this script"+@CRLF
Exit 0
EndIf

"MetaFrame Farm Name: "+$oFarm.FarmName+@CRLF+@CRLF

For Each $oApp In $oFarm.Applications
If @ERROR "ERROR: Cannot enumerate applications ["+@ERROR+"] "+@SERROR+@CRLF Exit @ERROR EndIf
$oApp.LoadData($TRUE)

"DistinguishedName: "+$oApp.DistinguishedName+@CRLF
" AppName: "+$oApp.AppName+@CRLF
" Description: "+$oApp.Description+@CRLF
If $oApp.AppType = $MetaFrameWinAppObject
$oWinApp = $oApp.WinAppObject
" WorkingDir: "+$oWinApp.DefaultWorkDir+@CRLF
" DefaultInitProg: "+$oWinApp.DefaultInitProg+@CRLF
EndIf
@CRLF
Next


Top
#160716 - 2006-04-18 08:49 AM Re: Get Published application
krex Offline
Fresh Scripter

Registered: 2006-03-02
Posts: 39
Thanks Richard!

Just one thing how do you know what numbers to initialize.
Fx.
$MetaFrameWinFarmObject=1
$MetaFrameWinAppObject=3

Is there a way to figurer this out cause then i would like know.

Thanks Again!

Top
#160717 - 2006-04-18 09:44 AM Re: Get Published application
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
There are two easy ways to find the values.

The first is to use a COM/OLE browser. Use this on a MetaFrame server to browse the Citrix COM objects - view the "enumerations" of the object, these are basically the object constants. You can use the object browser available in VBA if you want. This method will get you all the values, but can be confusing if you are not familiar with objects.

The second method which is simpler but can only be used if you know the enumeration name. In this case, just open the "immediate" window in VBA and type "debug.print ENUMERATION". For example, "debug.print MetaFrameWinFarmObject" would display "1".

The easiest way to get into VBA is to start Excel and open "Tools->Macro->Visual Basic Editor". You need to add the MetaFrame object reference to be able to use it, so in the VBA screen go to "Tools->References" and put a tick in the "Citrix MetaFrame COM Library" box.

You can now open the object browser by using "View->Object Browser" or the immediate window by "View->Immediate Window"

There are a number of stand-alone object browsers if you can't start VBA - there is even a KiXtart object browser available if you search the forum.

Top
#160718 - 2006-04-18 10:07 AM Re: Get Published application
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Here is a link to one from ASE at iTripoli

http://www.itripoli.com/itlv.asp

Top
#160719 - 2006-04-18 11:29 AM Re: Get Published application
krex Offline
Fresh Scripter

Registered: 2006-03-02
Posts: 39
Thanks!
Richard and NTDOC

Top
#160720 - 2006-04-20 09:22 AM Re: Get Published application
krex Offline
Fresh Scripter

Registered: 2006-03-02
Posts: 39
Hi!
I have to understand this and i cant seem to get it working. Now i want get the MFcom object: IMetaFrameContent Interface.
I done the debug.print MetaFrameContent and i get nothing i been using the Object Browser that dident make any sense. but if i write debug.print metaframewinfarmobject i get 1.

The MetaFrameContent is an interface so.....?

I need to know how you get from one object to anothere and the to an interface. I been reading Citrix SDK MFCOM and theres no help to beginners and i tryede reading othere things on the net.

Basic is i know how i se the properties/methodes of an object but i dont know how to get from object to object or interface. how do i get from classes to classes thats the ?

Hope this make sense

Top
#160721 - 2006-04-20 10:17 PM Re: Get Published application
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
I'd love to help you but I don't run a Citrix farm here anymore so I don't have the object to test / run for you.

Unless someone else here has experience with it you may have to wait for Richard to come online later tonight, he is in England.
 

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.062 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org