#191462 - 2008-12-29 12:16 PM
Re: Understanding COM
[Re: Gargoyle]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
|
Haven't read the manual yet, but the proper code should be
$obj = CreateObject("MyCOMLibrary.Class")
|
Top
|
|
|
|
#191463 - 2008-12-29 12:17 PM
Re: Understanding COM
[Re: Arend_]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
|
As the manual points out, this should be the kix code:
$SFTPServer = CreateObject("SFTPCOMInterface.CIServer")
|
Top
|
|
|
|
#191464 - 2008-12-29 12:30 PM
Re: Understanding COM
[Re: Arend_]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
|
I've translated this sample script for you, maybe it helps:
; 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 = ""
|
Top
|
|
|
|
#191474 - 2008-12-29 03:56 PM
Re: Understanding COM
[Re: Arend_]
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
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.
$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
_________________________
Today is the tomorrow you worried about yesterday.
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|