|
|
|||||||
Okay I am way over my head with my latest project. We have recently aquired an application that comes with support for full automation via COM. When I use the Type Library Explorer to view the COM file, I get a listing of bunch of classes with the COM, and then a list of the members of methods and property's within that class. Using the examples that they provided, I am creating an object as such Code: createobject(MyCOMLibrary.Class) I have to use one class to connect to the server application, and then need to use a different class to retrieve needed data. Do I have to create a new object for each new class? Or should I be creating my "root" class differently? Can I do something more like this. Code: createobject(system.MyCOMLibrary) And since someone is likely to ask ... This is for the EFT product from GlobalScape. |
||||||||
|
|
|||||||
Have you checked their manual or their web site to see whether they have COM examples? You should then be able to adjust thses to KiXtart. |
||||||||
|
|
|||||||
Their manual provides 3 examples, and they are confusing at best. Most of it reads like this. Quote: Use the ICISite Interface GetAuthManagerID method to identify or retrieve the authentication manager ID of a site. The authentication manager ID is the type of authentication used (GS Auth, NT/AD, or ODBC). Signature: HRESULT GetAuthManagerID([out, retval] long *prop); Where the ICISite Interface is a class in the DLL. You can see the manual here... http://help.globalscape.com/help/eft5_com/ |
||||||||
|
|
|||||||
So what kind of data are you needing when using this? |
||||||||
|
|
|||||||
Currently I need to list all of the "Events" within a single site and then ensure that they are disabled. Among other things. I can post some of my code on Monday if it would help me figure out what I am doing. I already have been able to list all of the Users in a given site and extract what their email address is, but this "Event" stuff is killing me. |
||||||||
|
|
|||||||
Haven't read the manual yet, but the proper code should be Code: $obj = CreateObject("MyCOMLibrary.Class") |
||||||||
|
|
|||||||
As the manual points out, this should be the kix code: Code: $SFTPServer = CreateObject("SFTPCOMInterface.CIServer") |
||||||||
|
|
|||||||
I've translated this sample script for you, maybe it helps: Code: ; FILE: CreateUserListSpreadSheet ; CREATED: 13 OCT 2004 GTH ; PURPOSE: List the users of a site and create an excel spreadsheet. ; $SFTPServer = CreateObject("SFTPCOMInterface.CIServer") $CRLF = Chr(13)+Chr(10) $txtServer = "192.168.134.142" $txtPort = "1000" $txtUserName = "admin" $txtPassword = "admin" $SFTPServer.Connect($txtServer, $txtPort, $txtUserName, $txtPassword) If @ERROR <> 0 ? "Error connecting to '"+$txtServer+":"+$txtPort+"' -- "@SERROR+" ["+CStr(@ERROR)+"]" Exit 255 Else ? "Connected to " + $txtServer EndIf $Sites = $SFTPServer.Sites $oExcel = CreateObject("Excel.Application") $oExcel.visible = 1 $oWorkbook = $oExcel.Workbooks.Add For $i=0 To $SFTPServer.Sites.Count-1 $theSite = $Sites.Item($i) $theSheet = $oWorkbook.Worksheets.add $theSheet.name = $theSite.Name $theSheet.Cells(1, 1) = "Users:" $arUsers = $theSite.GetUsers() For $j=0 To UBound($arUsers) $theSheet.Cells(($j+2), 1) = $arUsers($j) Next $theSheet.Columns("A:A").EntireColumn.Autofit Next $oExcel = "" $SFTPServer.Close $theSite = "" $SFTPServer = "" |
||||||||
|
|
|||||||
Apronk, thanks, but I was able to get that part working okay. I will post my script later today so all can see what I am attempting. Where I am having a problem is in an event class that they just exposed in the COM, and is not in their online documentation. In specific I do not understand how to read this... Quote: HRESULT GetAuthManagerID([out, retval] long *prop); |
||||||||
|
|
|||||||
To be honest, due to the properties I don't fully understand it either. From what I gather it the [out, retval] is a returning variable going out (something KiX doesn't support) the variable is of the type long (int). But I might be reading it totally wrong. Edit: Apparantly [out, retval] means that it is a returning variable as I just said, and the variable is of the type long, the numeric index of the property, I guess. However You won't be able to use it in KiX. KiX doesn;t support OUT paramenters, VBS does though.... I've asked for this OUT parameter support a couple of times already... |
||||||||
|
|
|||||||
Ok, so I may have to switch to PowerShell for this then. Here is the current code that I am working with, but will see what I can do with PS. Code: $SO=SetOption("Explicit", "ON") $SO=SetOption("NoMacrosInStrings", "ON") $SO=SetOption("NoVarsInStrings", "ON") $SO=SetOption("WrapAtEOL", "ON") ; Variable Declarations Dim $o_Server,$a_Sites,$s_Counter,$s_Site,$s_Events ; Instatiate the SFTP COM Object $o_Server = CreateObject(SFTPCOMInterface.CIServer) ; Connect to the server $o_Server.Connect('10.10.0.23','3000','admin','password') ; Retrieve a list of Sites $a_Sites=$o_Server.Sites ; See if the Site is stopped, if not Stop it For $s_Counter = 0 to UBound($a_Sites) $s_Site = $o_Server.Sites.Item($s_Counter) If $s_Site.IsStarted = 'True' $s_Site.Stop() EndIf Next ; Stop the EFT Server Service Shell '%comspec% sc \\server stop "GlobalScape EFT Server"' ; Wait for the service to stop While WMIService("GlobalScape EFT Server","Query",,"\\server") <> "Stopped" Loop ; Create backup of config on Server01 and Server02 to the DFS mount Copy "\\server\e$\Globalscape\ftp.dat" "\\server03\eftdata\eftconfig\server_config\ftp_"+Join(Split(@DATE,"/"))+".bak" Copy "\\server01\e$\Globalscape\ftp.dat" "\\server03\eftdata\eftconfig\server01_config\ftp_"+Join(Split(@DATE,"/"))+".bak" ; Overwrite the config on Server with the Master copy Copy "\\server01\e$\globalscape\ftp.dat" "\\server\e$\globalscape\" ; Start the EFT Server Service Shell '%comspec% sc \\server start "GlobalScape EFT Server"' ; Wait for the service to start While WMIService("GlobalScape EFT Server","Query",,"\\server") <> "Running" Loop ; Stop any sites that came up running For $s_Counter = 0 to UBound($a_Sites) $s_Site = $o_Server.Sites.Item($s_Counter) If $s_Site.IsStarted = 'True' $s_Site.Stop() EndIf Next ; Change the IP's to the correct one for each site. For $s_Counter = 0 to UBound($a_Sites) $s_IP = ReadProfileString("\\server03\eftdata\eftconfig\globalscape\config.ini","Sites",$a_Sites[$s_Counter]) $s_Site = $o_Server.Sites.Item($s_Counter) $s_Site.SetIP("10.10.0."+$s_IP) ; Need to find a way to change the gateway address as well ; Turn off all the event rules $s_Events = $s_Site. Next Function WMIService($service,$action,optional $startmode,optional $computer) ;Removed to make a shorter post |
||||||||
|
|
|||||||
Looks good, just a suggestion... you can stop and start services trough the same WMI manor too. |