Jump to content

Problem with Citrix COM object


Roman
 Share

Recommended Posts

Hi

I have a Citrix COM object which provides the following methodes:

PS  $lm|get-member

   TypeName: System.__ComObject#{29d9c0a3-5d2b-44b3-8ad9-0545be9ec17e}
Name                 MemberType Definition
----                 ---------- ----------
AttachLoadEvaluator  Method  void AttachLoadEvaluator (uint64, uint64, SA...
GetLMDisabledServers Method  SAFEARRAY(string) GetLMDisabledServers (string)
QueryServers         Method  SAFEARRAY(byte) QueryServers (uint64)
SetServerLMState     Method  void SetServerLMState (string, int)

With this PowerShell commands, i get the disired server name, in this case server "XXXXXXX181":

PS > $lm = New-Object -COM CPSCOMInterop.CPSLoadManager.1
PS > $srv=$lm.GetLMDisabledServers("XENAPP")
PS > $srv
XXXXXXX181

If i try to script that with AutoIt, i get a variable ($var) which content i can not use / or which has no content? $var contains no string, it is no array, i get no array dimensions and it is no object...?

$o_LM = ObjCreate("CPSCOMInterop.CPSLoadManager.1")
$var = $o_LM.GetLMDisabledServers("XENAPP")

Sorry, i'm not very familar with COM. May be somebody has any hints for an "COM beginner"?

Thanks and kind regards,

Roman.

Edited by roman
Link to comment
Share on other sites

First thing when working with COM objects is to implement a COM error handler.

So I would expand your script like:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler
$o_LM = ObjCreate("CPSCOMInterop.CPSLoadManager.1")
If @error <> 0 or Not IsObj($o_LM) Then Exit MsgBox(16, "Error", "Could not create object!")
$var = $o_LM.GetLMDisabledServers("XENAPP")
If @error <> 0 or Not IsObj($o_LM) Then Exit MsgBox(16, "Error", "Could not get Server!")
Exit

; This is my custom defined error handler
Func MyErrFunc()

  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"    & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "       & @TAB & hex($oMyError.number,8)  & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "       & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile     & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )

Endfunc
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler
$o_LM = ObjCreate("CPSCOMInterop.CPSLoadManager.1")
If @error <> 0 or Not IsObj($o_LM) Then Exit MsgBox(16, "Error", "Could not create object!")
$var= $o_LM.GetLMDisabledServers("XENAPP")
If @error <> 0 or Not IsObj($var) Then Exit MsgBox(16, "Error", "Could not get Server!")
Exit
; This is my custom defined error handler
Func MyErrFunc()
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"  & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "     & @TAB & hex($oMyError.number,8)  & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "     & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile   & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
Endfunc

Thank You for your replay

In line 5 it should be "$var" shouldn't it?

No COM error occurs! There ist not an error but $var is not an object.

Therefore the message "Could not get Server!" appears.

Do you have any other tips?

Thank you in advance Roman

Edited by roman
Link to comment
Share on other sites

Line 5? Right, should be $var.

The method name is GetLMDisabledServers so maybe it returns an array?

You could try:

#include <array.au3>
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler
$o_LM = ObjCreate("CPSCOMInterop.CPSLoadManager.1")
If @error <> 0 or Not IsObj($o_LM) Then Exit MsgBox(16, "Error", "Could not create object!")
$var= $o_LM.GetLMDisabledServers("XENAPP")
If @error <> 0 or Not IsObj($var) Then Exit MsgBox(16, "Error", "Could not get Server!")
If IsArray($var) Then
    _ArrayDisplay($var)
Else
    MsgBox(16, "Info", "Datatype of $var is: " & VarGetType($var))
Endif
Exit
; This is my custom defined error handler
Func MyErrFunc()
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"  & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "   & @TAB & hex($oMyError.number,8)  & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "   & @TAB & $oMyError.source     & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile   & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
Endfunc

If it is an array the array is displayed. If not the datatype of $var is displayed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Sorry, bat it doesn't work anyway. It seems to be an array as you can see from the Powershell get-member Command. It seems to be a SAFEARRAY. What ever a SAFEARRAY is.

#include <array.au3>
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler
$o_LM = ObjCreate("CPSCOMInterop.CPSLoadManager.1")
If @error <> 0 or Not IsObj($o_LM) Then Exit MsgBox(16, "Error", "Could not create object!")
$var= $o_LM.GetLMDisabledServers("XENAPP")
If @error <> 0 or Not IsObj($var) Then MsgBox(16, "Error", "Could not get Server!")
If IsArray($var) Then
MsgBox(0,"","")
    _ArrayDisplay($var)
Else
    MsgBox(16, "Info", "Datatype of $var is: " & VarGetType($var))
Endif
Exit
; This is my custom defined error handler
Func MyErrFunc()
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"  & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "   & @TAB & hex($oMyError.number,8)  & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "   & @TAB & $oMyError.source   & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile   & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
Endfunc

We get the result from if isarray with an error:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Temp\citrix.au3"

C:\Program Files\AutoIt3\Include\array.au3 (371) : ==> Array variable subscript badly formatted.:

Local $avArrayText[$iUBound + 1]

Local $avArrayText[^ ERROR

>Exit code: 1 Time: 4.593

If i remark Line 7 to 10 and line 12 I get the answer "Datatype of $var is: Array

Link to comment
Share on other sites

Then we should first gather some info about the array.

If IsArray($var) Then
  MsgBox(16, "Info", "Dimensions: " & UBound($var, 0))
  If UBound($var, 0) >= 1 then MsgBox(16, "Info", "Elements in 1st dimension: " & UBound($var, 1))
  If UBound($var, 0) > 1 then MsgBox(16, "Info", "Elements in 2nd dimension: " & UBound($var, 2))
EndIf
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

So the method returned a valid result: a 1-dimensional array with no entries.

What do you get if you just call:

$var= $o_LM.GetLMDisabledServers()
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok, then try

$var= $o_LM.GetLMDisabledServers("")

BTW:

Do you know what parameters the method requires? Just one or could there be more? Of what type should the parameters be string, array?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You are sure it's a string? Do you have a documentation of the COM interface? Sometimes methods require to pass an array.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Savearray seems to be a C++ thing (according to google). Maybe AutoIt can't handle this kind of datatype or has to handle it different.

I don't write C++ so maybe some of the C++ gurus here knows how to access the result?

SaveArrays

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hier noch eine gute Beschreibung von SaveArrays auf deutsch. (A good description of what Savearrays are written in german)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The only problem I see here is SAFEARRAY(string)? What's that?

AutoIt understands plenty of COM types, but apparently not this one. I can add another which I think this one could be, but it would be better if the real type could be confirmed first.

@roman, send me PM and I will tell you what to do if you want.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...