[MFCOM] SendMessage

Bonjour a tous ,



Je suis en train de développer un script mais j’ai du mal a debuger l’erreur que j’obtiens.



Le but etant d’envoyer un message aux personnes actuellement connectées a une application donnée.





Voici mon script :



Set ArgObj = WScript.Arguments
AppName = ArgObj(0)
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."


WScript.Echo "Application Name: " & AppName

Set oFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
oFarm.Initialize(1)


For each oApplication in oFarm.Applications
oApplication.LoadData(1)

If oApplication.AppName = "Toto" Then
For Each oSession in oApplication.Sessions

ServerName = oSession.ServerName
SessionID = oSession.SessionID
UserName = oSession.Username
ClientName = oSession.ClientName
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."
SessionState = oSession.SessionState

If UserName <> "" Then

wscript.echo ServerName
wscript.echo SessionID
wscript.echo UserName
wscript.echo ClientName

oSession.SendMessage ServerName,SessionID, UserName, ClientName, strTitle, strMsg, 1, 120000, 0


End If

Next
End If
Next





J'obtiens comme erreur : error unspecified sur la ligne ou il y a la sub SendMessage.

Auriez vous une idée ?

voici ton script corrigé et fonctionnel ( testé sur xenapp 5/2008 )

j’ai rajouté la detection de connexion afin de ne pas avoir d’erreur sur les user dont l’etat est déconnecté








Send message to spÈcific application users


CScript //nologo sendMessage.wsf ApplicationName








'SendMessage
'
'

Set ArgObj = WScript.Arguments
AppName = ArgObj(0)
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."


WScript.Echo "Application Search Name: " & AppName

Set oFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
oFarm.Initialize(1)


For each oApplication in oFarm.Applications
oApplication.LoadData(1)
If oApplication.AppName = AppName Then
wscript.echo "Application search : OK"
For Each oSession in oApplication.Sessions

ServerName = oSession.ServerName
SessionID = oSession.SessionID
UserName = oSession.Username
ClientName = oSession.ClientName
strTitle = "System Maintenance Reminder"
strMsg = "Please log off in 5 minutes due to regular system maintenance."
SessionState = oSession.SessionState
wscript.echo UserName & "session state: "& SessionState
If UserName "" and SessionState = 1 Then


wscript.echo "User " & UserName & " on " & ServerName & " with the session ID: " & SessionID

oSession.SendMessage ServerName,SessionID, UserName, ClientName, strTitle, strMsg, 0, 120000, 0


End If

Next
End If
Next



toi yen a pouvoir utiliser Citrix Logoff Sessions aussi http://support.citrix.com/article/CTX124949