home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 October / PCWorld_2006-10_cd.bin / komunikace / cuteftp / cuteftppro.exe / Disk1 / data1.cab / SampleVBSScripts / Scripts / sample.vbs
Encoding:
Text File  |  2006-08-23  |  3.1 KB  |  77 lines

  1. 'This default template script is in VBScript. You can write scripts in your language of choice and save them with the proper extension, or use your an editor specific to that language.
  2.  
  3. 'See the TESDK help file for more details on how the scripting feature works and for information on each supported method and property.
  4.  
  5. 'You must have Windows Scripting Host installed for the COM enabled engine to work. Run the Transfer Engine once to register it (as a COM object) on the target system.
  6.  
  7. 'If you're having problems with running scripts while not logged in, or when trying to run them using MS scheduler, refer to our online knowledgebase for help (http://www.globalscape.com/support)
  8.  
  9. 'Look into c:\temp folder to observe local activity (for testing purposes) or right click on the Transfer Engine icon in the systray and select "show current transfers"
  10.  
  11. 'This sample script performs an anonymous login to ftp://ftp.globalscape.net
  12.  
  13.    'First declare a variable called Mysite. This will hold the reference to the TE COM object.
  14.  
  15.    Dim MySite
  16.  
  17.    'Create a connection object and assign it to the variable
  18.  
  19.    Set MySite = CreateObject("CuteFTPPro.TEConnection")
  20.     
  21.    ' Now set each property for the site connection 
  22.    ' You can omit this section to use the default values, but you should at least specify the Host
  23.    'The default Protocol is FTP, however SFTP (SSH2), FTPS (SSL), HTTP, and HTTPS can also be used)
  24.  
  25.    MySite.Protocol = "FTP"
  26.    MySite.Host = "ftp.globalscape.com"
  27.  
  28.    'following lines are optional since the default is anonymous if no login and password are defined
  29.  
  30.    MySite.Login = "anonymous"
  31.    MySite.Password = "user@user.com"
  32.  
  33.    'if necessary, use the UseProxy method and ProxyInfo or SocksInfo properties to connect through a proxy server
  34.  
  35.    MySite.UseProxy = "BOTH"
  36.  
  37.    'now connect to the site (also called called implicitly when most remote methods are called)
  38.  
  39.    MySite.Connect
  40.  
  41.     
  42.    'perform some logic to verify that the connection was made successfully
  43.  
  44.    If (Not Cbool(MySite.IsConnected)) Then    
  45.       MsgBox "Could not connect to: " & MySite.Host & "!"
  46.       Quit(1)
  47.    End If
  48.  
  49.    'The script will now check to see if the local folder c:\temp exists and will create it if necessary
  50.  
  51.    If (Not (MySite.LocalExists("c:\temp"))) Then
  52.       MySite.CreateLocalFolder "c:\temp"
  53.    End If
  54.  
  55.    'Change TE's local working folder to to c:\temp
  56.    MySite.LocalFolder = "c:\temp"
  57.  
  58.    'Check for existence of remote folder "/pub/cuteftp"
  59.    b = MySite.RemoteExists("/pub/cuteftp/")
  60.  
  61.    If (Not CBool(b)) Then
  62.       'Verify existence of remote folder
  63.       MsgBox "Remote folder not found!. Please make sure that the Pub folder exists on the remote site"
  64.       Quit(1)
  65.    End If
  66.  
  67.    'Now download the index file to the local destination folder
  68.    MySite.Download "/pub/cuteftp/index.txt"
  69.  
  70.    'Complete.  Show the status of this transfer.
  71.    MsgBox "Task done, final status is '" + MySite.Status + "'"
  72.  
  73.   MySite.Disconnect
  74.   MySite.Close
  75.  
  76. 'End of sample script. You can save you script and then run it by either selecting it from the Tools > Run Script menu or by double clicking on the script file in Windows
  77.