This is a mirror of official site: http://jasper-net.blogspot.com/

Scripting the SmartFTP Client

| Sunday, May 9, 2010
In my last blog post I reviewed the SmartFTP Client, where I briefly mentioned that the SmartFTP Client has built-in extensibility support, and I promised to include a script that I've been testing. I have made it abundantly obvious in many of my earlier blog posts that I love writing scripts or extending the functionality of existing products whenever I can, so having built-in extensibility for an FTP client definitely caught my interest.

To begin with, you can download the SDK for the SmartFTP Client form the following URL:

http://www.smartftp.com/features/sdk/

The SDK will give you a couple of CHM files that contain the documentation for the SmartFTP Client extensibility features and a handful of samples to get you started. After I downloaded the SDK I spent some time looking at the documentation and a few of the existing samples, and I was able to create a simple FTP client pretty easily based on what I had seen.

So without further discussion, here is the annotated sample that I have been testing:

Option Explicit

' Bypass any errors.
On Error Resume Next

' Declare the object variables.
Dim objSmartFTP
Dim objFTPConnection

' Define some constants.
' Note: These are from the CHM file in the SDK.
Const ftpProtocolNormal = 0
Const ftpErrorSuccess = 0

' Try to retrieve an exsting object for the SmartFTP client.
Set objSmartFTP = GetObject("SmartFTP.Application")

' Test if we were able to get an exsting object.
If TypeName(objSmartFTP) <> "Application" Then
  ' Instantiate a new instance if no client is present.
  Set objSmartFTP = WScript.CreateObject("SmartFTP.Application")
End If

' Hide the SmartFTP client.
objSmartFTP.Visible = False

' Create a connection object.
Set objFTPConnection = objSmartFTP.CreateObject("sfFTPLib.FTPConnectionSTA")

' Specify the connection properties.
objFTPConnection.Host = "ftp.example.com"
objFTPConnection.SendHOST = True
objFTPConnection.Username = "foo"
objFTPConnection.Password = "bar"
objFTPConnection.Port = 21
objFTPConnection.Protocol =  ftpProtocolNormal
objFTPConnection.Passive = True
objFTPConnection.MLST = True


Read more: Robert McMurray's Blog [MSFT]

Posted via email from jasper22's posterous

0 comments: