I know I could use FTP from VBScript using something like the following.
However, is there a better way to do this so it's a little more
"interactive" (i.e., allow the script to interpret intelligently the
response from the server after issuing each command before continuing. e.g.
iff cannot open connection to servername, then it might be worth waiting a
while and then retrying instead of sending a username).

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

sFtpCmds = "c:\ftp.inp"

Set fFtpCmds = oFSO.CreateTextFile(sFtpCmds, _
OverwriteIfExist, OpenAsASCII)

' server to open
fFtpCmds.WriteLine "open servername"
' username
fFtpCmds.WriteLine "username"
' password
fFtpCmds.WriteLine "password"
fFtpCmds.WriteLine "GET testfile.txt"
fFtpCmds.WriteLine "quit"

fFtpCmds.Close

sCmd = "ftp -i -s:" & sFtpCmds

oShell.Run sCmd, 0

Re: Interactive FTP VBScript by Torgeir

Torgeir
Wed Jan 21 16:40:35 CST 2004

Patrick wrote:

> I know I could use FTP from VBScript using something like the following.
> However, is there a better way to do this so it's a little more
> "interactive" (i.e., allow the script to interpret intelligently the
> response from the server after issuing each command before continuing. e.g.
> iff cannot open connection to servername, then it might be worth waiting a
> while and then retrying instead of sending a username).

Hi

Take a look at the components below. They wrap WinInet.dll in a object you can
use from a VBScript:


Ian Morrish's FAQ at http://groups.msn.com/WindowsScript/othercomobjects.msnw
- Free FTP COM Object & sample script
and not so free:
- Is there an FTP COM object that I can use with WSH?

AspFTP (free)
http://www.15seconds.com/issue/981203.htm

AspInet (free)
http://www.serverobjects.com/comp/AspInet.zip


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: Interactive FTP VBScript by Patrick

Patrick
Thu Jan 22 05:41:16 CST 2004

I like the first artiicle, but how could I reference a DLL and do something
like the following in a VBScript (as opposed to a VB EXE Application)?
Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName
As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

Event removing the "ByVal", "As String" etc it's still coming up as a syntax
error as VBScript does not recognise the keywords like Declare.

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:400EFFE2.6645EB7D@hydro.com...
>
> Take a look at the components below. They wrap WinInet.dll in a object you
can
> use from a VBScript:
>
>
> Ian Morrish's FAQ at
http://groups.msn.com/WindowsScript/othercomobjects.msnw
> - Free FTP COM Object & sample script
> and not so free:
> - Is there an FTP COM object that I can use with WSH?
>
> AspFTP (free)
> http://www.15seconds.com/issue/981203.htm
>
> AspInet (free)
> http://www.serverobjects.com/comp/AspInet.zip
>
>
> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter
>
>



Re: Interactive FTP VBScript by Torgeir

Torgeir
Thu Jan 22 06:13:19 CST 2004

Patrick wrote:

> I like the first artiicle,

This one you mean?

http://groups.msn.com/WindowsScript/othercomobjects.msnw?action=view_list&row=4&viewtype=2&sortstring=



> but how could I reference a DLL and do something
> like the following in a VBScript (as opposed to a VB EXE Application)?
> Private Declare Function InternetOpen Lib "wininet.dll" Alias

You can't call API's from a VBScript. To use the example in the link above, you
need to run the exe file vbInet.exe that is inside the zip file vbInet.zip once
(it is a self registering exe file). vbInet.exe is a component that wraps the
API's so you can use it from a vbscript.

After you have run vbInet.exe, you can connect to the object like this:

Set oInet = CreateObject("VBInet.CNetUpload","oInet_")


For the other links I gave you, here is what you need to do before it will work
from a vbscript:

1)
AspFTP (free)
http://www.15seconds.com/issue/981203.htm

Download 981203.zip and unpack it. Register the dll aspftp.dll:

regsvr32.exe "<some path>\aspftp.dll"
(if you want to register it unattended, use regsvr32.exe /s ....)

you can then connect to the object like this:

Set oFTP = CreateObject("NIBLACK.ASPFTP")


2)
AspInet (free)
http://www.serverobjects.com/comp/AspInet.zip

Download AspInet.zip and unpack it. Register the dll ASPINET.DLL:

regsvr32.exe "<some path>\ASPINET.DLL"
(if you want to register it unattended, use regsvr32.exe /s ....)

you can then connect to the object like this:

Set oFTP = CreateObject("AspInet.FTP")

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: Interactive FTP VBScript by Patrick

Patrick
Fri Jan 23 19:02:03 CST 2004

Very strangely, with "NIBLACK.ASPFTP", I could get it successfully working
on Windows XP Professional SP2 with IE6SP1, but on a Windows 2000 Server
with SP4 and IE6 with SP1, when I call the oFTP.bConnect, having set the FTP
Server, FTP User name and password properties first, the method returns
False (which indicates a failure), the sError property is not populated
however. There are no errors, however, on creating the object.

However, if I manually try a FTP from the command prompt, I could
successfully connect and authenticate.

what is the likely problem and how could I set about tracking down the
problem? Note that the error number property does not mean much to me
either, just a negative number which does not even correspond to any errors
a FTP server can return!


"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message > 1)
> AspFTP (free)
> http://www.15seconds.com/issue/981203.htm
>
> Download 981203.zip and unpack it. Register the dll aspftp.dll:
>
> regsvr32.exe "<some path>\aspftp.dll"
> (if you want to register it unattended, use regsvr32.exe /s ....)
>
> you can then connect to the object like this:
>
> Set oFTP = CreateObject("NIBLACK.ASPFTP")
>
>
> 2)
> AspInet (free)
> http://www.serverobjects.com/comp/AspInet.zip
>
> Download AspInet.zip and unpack it. Register the dll ASPINET.DLL:
>
> regsvr32.exe "<some path>\ASPINET.DLL"
> (if you want to register it unattended, use regsvr32.exe /s ....)
>
> you can then connect to the object like this:
>
> Set oFTP = CreateObject("AspInet.FTP")
>
> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter
>
>



Re: Interactive FTP VBScript by Torgeir

Torgeir
Sat Jan 24 19:57:59 CST 2004

"Torgeir Bakken (MVP)" wrote:

> To use the example in the link above, you
> need to run the exe file vbInet.exe that is inside the zip file vbInet.zip once
> (it is a self registering exe file). vbInet.exe is a component that wraps the
> API's so you can use it from a vbscript.
>
> After you have run vbInet.exe, you can connect to the object like this:
>
> Set oInet = CreateObject("VBInet.CNetUpload","oInet_")

Oops, that needs to be

Set oInet = WScript.CreateObject("VBInet.CNetUpload","oInet_")


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter



Re: Interactive FTP VBScript by Patrick

Patrick
Sat Mar 06 20:27:59 CST 2004

Has anyone used any of the following FTP DLL Wrapper to wininet.dll?

They seem to work OK for small files. It's hard to tell where the problem
lies.

For instance, with the slightly more advance ASPInet.dll, the
FtpConn.FTPPutFile method returns false when I tried to upload a 70MB binary
file on a remote server running the latest version of Bullet Proof FTP
Server. The remote BFTP Server logs it as Transfer aborted.

Is a FTP with ASPInet.dll, or indeed a hand-crafted DLL wrapper to
wininet.dll any less "reliable" than using the FTP command from the command
prompt in Windows 2000?

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:400EFFE2.6645EB7D@hydro.com...
> Patrick wrote:
>
> > I know I could use FTP from VBScript using something like the following.
> > However, is there a better way to do this so it's a little more
> > "interactive" (i.e., allow the script to interpret intelligently the
> > response from the server after issuing each command before continuing.
e.g.
> > iff cannot open connection to servername, then it might be worth waiting
a
> > while and then retrying instead of sending a username).
>
> Hi
>
> Take a look at the components below. They wrap WinInet.dll in a object you
can
> use from a VBScript:
>
>
> Ian Morrish's FAQ at
http://groups.msn.com/WindowsScript/othercomobjects.msnw
> - Free FTP COM Object & sample script
> and not so free:
> - Is there an FTP COM object that I can use with WSH?
>
> AspFTP (free)
> http://www.15seconds.com/issue/981203.htm
>
> AspInet (free)
> http://www.serverobjects.com/comp/AspInet.zip
>
>
> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter
>
>