Windows Scripting
  Home arrow Windows Scripting arrow How to Easily Use FTP in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

How to Easily Use FTP in WSH
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-09-04

    Table of Contents:
  • How to Easily Use FTP in WSH
  • Uploading and Downloading files
  • Extending the Chilkat FTP ActiveX control
  • Creating a Text File

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    How to Easily Use FTP in WSH


    (Page 1 of 4 )

    In my last article I showed you a work around that allowed you to use FTP in WSH. This time I’m going to show you a much easier, more flexible approach using a third-party ActiveX control designed to expand WSH.

    ActiveX controls can be used to add functionality to WSH that it does not have natively. The ActiveX must be written for this purpose and must provide a COM interface. Once the ActiveX control is instantiated in your script, you will be able to access all of the methods and properties that it provides.

    ActiveX controls must be installed on the system on which they are being used. Simply referencing a file is not enough. To install an ActiveX control, it must be registered, meaning that a set of registry keys must be created that reference it as a COM object. Many third parties will include installers for this.

    If your ActiveX control does not have an installer, you can register it yourself from the command line. Navigate to the directory where your control is located and use the command regsvr32 activex.ocx with the name of your control.

    We’ll be using Chilkat’s Free FTP ActiveX control. This ActiveX control acts as a sort of scriptable FTP client that provides access to the most common FTP functions. There are two versions—one free and one commercial. While we’ll be using the free control for this demonstration, the paid version offers some very cool functionality.

    Once you’ve installed the control, you’ll be able to access it through its COM interface by connecting to the ChilkatFTP.ChilkatFTP namespace.

    Set objFtp = CreateObject("ChilkatFTP.ChilkatFTP")

    Next you’ll want to make a connection. To do that you’ll need to provide the hostname, username, and password. The FTP control provides properties for this.

    objFtp.Hostname = "ftp.mysite.com"

    objFtp.Username = USERNAME

    objFtp.Password = PASSWORD

    success = objFtp.Connect()

    Finally, the Connect method makes the connection. Be sure to catch the return code for error handling purposes.

    If (success <> 1) Then

       Wscript.Echo objFtp.LastErrorText

       Wscript.Quit

    End If

    More Windows Scripting Articles
    More By Nilpo


       · In a follow-up to my "Using FTP in WSH" article, we will examine a much easier FTP...
     

    WINDOWS SCRIPTING ARTICLES

    - Printing Documents in WSH
    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory
    - Moving and Renaming Computers with Active Di...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway