Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to upload file to FTP server in VBS?

2,604 views
Skip to first unread message

MS

unread,
Mar 14, 2004, 11:48:41 PM3/14/04
to
Does anyone know how to use FTP in VBS to upload file? I want upload a txt
file to server in VBS.


Much thanks,

Don Grover

unread,
Mar 15, 2004, 1:01:31 AM3/15/04
to
I dont no where this came from, but it works.

Dim sMyWebsite, sUsername, sPassword, sFromFolder, sToFolder1, sToFolder2,
sFileName1, sFilename2
Set oShell = CreateObject("Wscript.Shell")

'FTP Upload to specified server
'**** Change these variables to suit
************************************************************
sMyWebSite = "testt.no-ip.org" ' This is are web site we need to upload to
sUserName = "yourusername" ' This is the user name we need to access
website with
sPassword = "yourpassword" ' This is the password we need to upload
sFromFolder = "c:\files" ' This is the folder we are getting all
files from

sFileName1 = "archive.exe" ' This is the first file we need to upload
sFileName2 = "file2.csv" ' This is the second file we need to
upload
' NOTICE / is backwards and is actual server path
sToFolder1 = "c:/files/path1" ' This is the first folder we want
to put all files
sToFolder2 = "c:/files/path2" ' This is the second folder we want
to put all files
'***************************************************************************
************************

' file to be created with instructions for ftp.exe
sFtpInp = "c:\instructions.ftp"

With CreateObject("Scripting.FileSystemObject")
With .CreateTextfile(sFtpInp, True)
.WriteLine "open " & sMyWebSite
.WriteLine "user " & sUsername
.WriteLine sPassword
.WriteLine "lcd " & sFromFolder
.WriteLine "cd " & sToFolder1
.WriteLine "mput " & sFilename1
.WriteLine "cd " & sToFolder2
.WriteLine "mput " & sFileName1
.WriteLine "Close"
.WriteLine "Quit"
.Close
End With
oShell.Run "%windir%\system32\ftp.exe -i -n -s:" & sFtpInp, 1, True
.DeleteFile sFtpInp
End With


"MS" <deck...@mail.listtool.com> wrote in message
news:uwLHyikC...@TK2MSFTNGP12.phx.gbl...

MS

unread,
Mar 15, 2004, 10:02:01 AM3/15/04
to
Much thanks, Don..............

MS


"Don Grover" <spam...@assoft.com.au> wrote in message
news:O73W8LlC...@TK2MSFTNGP09.phx.gbl...

mike

unread,
Mar 18, 2004, 1:49:37 AM3/18/04
to
Or you could do it with half the code in a batch file to call FTP .....

"MS" <deck...@mail.listtool.com> wrote in message
news:uwLHyikC...@TK2MSFTNGP12.phx.gbl...

0 new messages