Roman Posted December 6, 2011 Share Posted December 6, 2011 (edited) 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 December 6, 2011 by roman Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 (edited) 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 December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Roman Posted December 6, 2011 Author Share Posted December 6, 2011 (edited) $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 _ ) EndfuncThank You for your replayIn 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 December 6, 2011 by roman Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Roman Posted December 6, 2011 Author Share Posted December 6, 2011 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 More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 (edited) 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 December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Roman Posted December 6, 2011 Author Share Posted December 6, 2011 Dimensions: 1 Elements in 1st dimensin: 0 Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 (edited) 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 December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Roman Posted December 6, 2011 Author Share Posted December 6, 2011 COM Error! Invalid number of parameters 8002000E Line 5 Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 (edited) 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 December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Roman Posted December 6, 2011 Author Share Posted December 6, 2011 the same behavior! I know that the method requires a string (only one!) and thap "XENAPP" is the right string (as you can see from the powershell commands) Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Roman Posted December 6, 2011 Author Share Posted December 6, 2011 I'm sure it is a string: GetLMDisabledServers Method SAFEARRAY(string) GetLMDisabledServers (string) Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 (edited) 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 December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted December 6, 2011 Share Posted December 6, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
trancexx Posted December 7, 2011 Share Posted December 7, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now