Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP VBScript w Progress Bar

Status
Not open for further replies.

WizTheOz

Programmer
May 14, 2004
3
US
My goal is to figure out a way to add a progress bar to an already existing FTP script that is running in VBScript. This script currently runs fine just FTPing the file(s), but I would like to be able to see a progress bar that shows how far along the transfer is.

<----------------- BEGIN ------------------->

sub MultipleFileFTP

Dim vbYesNoCancel: vbYesNoCancel = 3
Dim vbQuestion: vbQuestion = 32
Dim vbYes: vbYes = 6
Dim vbNo: vbNo = 7
Dim vbCancel: vbCancel = 2


FTPFile = "c:\ftpscript.txt"

set fso = CreateObject("Scripting.FileSystemObject")
set ws = CreateObject("WScript.Shell")
set qallist=ActiveDocument.Fields("Quote").GetPossibleValues
Quotes=qallist.Item(0).Text
set ftpfromallist=ActiveDocument.Fields("Document FTP Name").GetPossibleValues
set ftptoallist=ActiveDocument.Fields("New Document Launch Name").GetPossibleValues
set tofolderlist=ActiveDocument.Fields("New Folder Launch Name").GetPossibleValues
set docsizelist=ActiveDocument.Fields("Document Size").GetPossibleValues

'Open file with 2(write) initializes the file and erases any existing data
if fso.FileExists(FTPFile) then
set open_file = fso_OpenTextFile(FTPFile, 2)
else
set open_file = fso_OpenTextFile(FTPFile, 2, "True")
end if

open_file.WriteLine "open ftp.mysite.com"
open_file.WriteLine "myuser"
open_file.WriteLine "mypass"

for f=0 to tofolderlist.Count-1
newfolder=tofolderlist.Item(f).Text
if fso.FolderExists("C:\Download Folder") then
else
fso.CreateFolder("C:\Download Folder")
end if

if fso.FolderExists("C:\Download Folder\" & newfolder) then
else
fso.CreateFolder("C:\Download Folder\" & newfolder)
end if
next

for i=0 to ftpfromallist.Count-1
FTPFrom=ftpfromallist.Item(i).Text
FTPTo=ftptoallist.Item(i).Text
filesize=docsizelist.Item(i).Number
totalsize=totalsize + filesize

open_file.WriteLine "get " & Quotes & FTPFrom & Quotes & " " & Quotes & FTPTo & Quotes

next

open_file.WriteLine "QUIT"
open_file.Close()

rtnvalue = msgbox ("The size of the file(s) you wish to download is " & FormatNumber(totalsize/1048576,0) & " Mbytes", vbYesNoCancel + vbQuestion)

if rtnvalue = 6 then
'FTP the file
retmsg = ws.Run("ftp -s:"& Quotes & FTPFile & Quotes,1,"TRUE")

if retmsg = 0 Then
MsgBox("The FTP process has completed normally...")
Else
MsgBox("Error, the FTP process has NOT completed." & CHR(13) & "Please check your input and try again.")
End If
End if

end sub

<----------------- END ------------------->

Thanks
Oz
 
working on a similar process.
i am building an .hta that builds the ftp script.
my problem is if the user enters bad user/password, the upload fails, but ftp returns 0 as if it worked.

i am looking into - ws.Exec(~~~) - it is supposed to let me see StdOut.

ftp does not communicate back, but you could break it up into a series of ftp scripts - verry gross.

have you looked into InetCtls? i could not get it to work in my .hta - but it might give you amounts transferred.
hth
bryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top