vbs script how to auto dowload files from ftp to local machine

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got no idea how to get a files from ftp server to a local machine
using visual basic scripts.... is anybody who can help me?
I try that code:


SET o = CreateObject("ADODB.Connection")
IF o.FtpConnect("ftp.name.xxx", "username", "pass") Then
IF o.FtpGetFileEx("/folder/file.txt","c:\file.txt") Then
Return
RETURN o.FtpClose(ftp.priceles.com)
END IF
END IF

I don't know VBS scripts as well as i want but I'm not able to find
good idea how to do it... Thx for answer
 
http://www.paulsadowski.com/WSH/getremotebinaryfile.htm Works fine for text
files too.
Imagefile is the name of the local file; DestFolder is the name of the local
folder wher the file will be saved.

ImageFile = "default.asp"
DestFolder = "C:\temp"
URL = "ftp://ftp.yourhost.com/html/default.asp"

Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False, "user", "pass"
xml.Send

set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1

oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody

' Do not overwrite an existing file
oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist

' Use this form to overwrite a file if it already exists
' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite

oStream.close

set oStream = nothing
Set xml = Nothing
 
Paul R. Sadowski said:
http://www.paulsadowski.com/WSH/getremotebinaryfile.htm Works fine for text
files too.
Imagefile is the name of the local file; DestFolder is the name of the local
folder wher the file will be saved.

ImageFile = "default.asp"
DestFolder = "C:\temp"
URL = "ftp://ftp.yourhost.com/html/default.asp"

Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False, "user", "pass"
xml.Send

set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1

oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody

' Do not overwrite an existing file
oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist

' Use this form to overwrite a file if it already exists
' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite

oStream.close

set oStream = nothing
Set xml = Nothing
And if I had message that Adobe.strema object can not be create?
what should I do?
 
atr_spam said:
And if I had message that Adobe.strema object can not be create?
what should I do?

I don't know. Perhaps it was disabled by KB870669? Can anyone confirm this?

Look for a copy of WGET for Windows, I might suggest.
 
Works fine on my XPPro with all updates. As stated in KB870669 it disables
Adodb.Stream object in IE only. So it shouldn't the case when vbs is running
by means of cscript/wscript.

I know it may sound silly, but it can be a syntax error issue. Taking in
account a typo by atr_spam naming an object "Adobe.strema"... atr_spam, be
sure to copy and paste script from Paul's post and change only what needs to
be changed (filename,path,URL,login/pass).

Hope this helps,
Al.
 
Alexander Suhovey said:
Works fine on my XPPro with all updates. As stated in KB870669 it disables
Adodb.Stream object in IE only. So it shouldn't the case when vbs is
running
by means of cscript/wscript.

I know it may sound silly, but it can be a syntax error issue. Taking in
account a typo by atr_spam naming an object "Adobe.strema"... atr_spam, be
sure to copy and paste script from Paul's post and change only what needs
to
be changed (filename,path,URL,login/pass).

Now that I think of it, it could also be an Anti-Virus program with
script-blocking on, even some software firewalls do that.
 
Paul R. Sadowski said:
http://www.paulsadowski.com/WSH/getremotebinaryfile.htm Works fine for text
files too. [snipped Paul's code]
atr_spam said:
I've got no idea how to get a files from ftp server to a local machine
using visual basic scripts.... is anybody who can help me? [snip]
I don't know VBS scripts as well as i want but I'm not able to find
good idea how to do it... Thx for answer
And if I had message that Adobe.strema object can not be create?
what should I do?

?Adobe.strema?

There are plenty of scriptable FTP solutions available, e.g. Kermit.
Some CLIs also provide FTP capabilities. e.g. 4NT. These are IMHO easier
to script than VBS (XMLHTTP).
 
Back
Top