Windows DatabaseebooksStatistical Information

LWE10056 : Howto automate FTP with vbscript and windows scripting host for free

Symptom:

Difficulties automating FTP transfers

Cause:

none

Solution:

Some developers think they need a third-party tool or some complex source code to do FTP. There is an easier way to do FTP with scripting windows scripting host. The FTP executable from Windows has a command line option for running scripts.  You can schedule regular FTP scripts using Task Scheduler. (AT command)

You should make a text file for the script which can be used as parameter for the ftp command and and put your ftp command in it.

open your.ftp.site.comusername
password
prompt
cd tfptest
cd download
bin
mget testfile*
quit

The script above would FTP to your.ftp.site.com and do a logon with username and password. Then it changes directory and gets some testfiles. You can run this script in visual basic Script like:

Set objShell = CreateObject("WScript.Shell")

objShell.Run "cmd /c c:\winnt\system32\ftp.exe -s:filename" >> " & FTPLogfile, 1, True

Set objShell = Nothing

The FTPLogfile is optional and can be used to do some logging. We use this for automating ftp.


Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!
Copyright © 2004-2011 Lubby (V3.0.10 Aug 2011)
Sponsored by Keskon.
Statistical information by Google Analytics