ftping with wsh 
Author Message
 ftping with wsh

Is there away to automate ftping a file with wsh ? I am sure it
is simple....

thanks,
scott



Mon, 05 Mar 2001 03:00:00 GMT  
 ftping with wsh
Maybe there's a better way, but here's what works for me:

    Option Explicit
    Const vbMinimizedNoFocus = 6

    Dim WshShell
    Dim Result
    Dim rc

    rc = MsgBox("Upload?", vbOKCancel + vbInformation, "Upload...")

    if rc = vbCancel then
       WScript.Quit
    end if

    Set WshShell = WScript.CreateObject("WScript.Shell")

    Result = WshShell.Run("cmd /c ftp.exe -s:d:\projects\upload.scr >
d:projects\upload.results", vbMinimizedNoFocus, True)

In your 'upload.scr' file, just put the commands you want to pass to
ftp.exe, eg.

open ftp.mydomain.com
myuserid
mypassword
cd ftp/mydirectory
put myfile.exe
bye

HTH

Steve
http://www.pegasustools.com

Quote:
>Is there away to automate ftping a file with wsh ? I am sure it
>is simple....

>thanks,
>scott



Tue, 06 Mar 2001 03:00:00 GMT  
 ftping with wsh
I have been trying a few ActiveX FTP controls
like http://www.mabry.com/ftp/ The problem with most things written for VB
is that the are very event driven. This one can be run in synchronous mode.
It can also get directory listings etc.
Sample code...

On Error Resume Next
set mFTP1 = createObject("Mabry.FtpCtrl")
mFTP1.Blocking = True 'Synchronous mode
mFTP1.LogonName = "anonomous"
mFTP1.LogonPassword = "password"
mFTP1.Host = "ftp.microsoft.com"
mFTP1.Connect
if Err.Number=0 Then
    mFTP1.SrcFilename = "filename.ext"
    mFTP1.DstFilename = "C:\temp\filename.ext"
    mFTP1.GetFile
    If Err.Number <> 0 then
     WshShell.popup "Failed to copy file"
    End If
mFTP1.Disconnect
Else
    WshShell.popup "Failed to connect to server"
End If

Ian Morrish
WSH FAQ http://wsh.glazier.co.nz
Home page http://www.glazier.co.nz
NetMeeting http://ils.glazier.co.nz

Quote:

>Maybe there's a better way, but here's what works for me:

>    Option Explicit
>    Const vbMinimizedNoFocus = 6

>    Dim WshShell
>    Dim Result
>    Dim rc

>    rc = MsgBox("Upload?", vbOKCancel + vbInformation, "Upload...")

>    if rc = vbCancel then
>       WScript.Quit
>    end if

>    Set WshShell = WScript.CreateObject("WScript.Shell")

>    Result = WshShell.Run("cmd /c ftp.exe -s:d:\projects\upload.scr >
>d:projects\upload.results", vbMinimizedNoFocus, True)

>In your 'upload.scr' file, just put the commands you want to pass to
>ftp.exe, eg.

>open ftp.mydomain.com
>myuserid
>mypassword
>cd ftp/mydirectory
>put myfile.exe
>bye

>HTH

>Steve
>http://www.pegasustools.com

>>Is there away to automate ftping a file with wsh ? I am sure it
>>is simple....

>>thanks,
>>scott



Wed, 07 Mar 2001 03:00:00 GMT  
 ftping with wsh
Another one to look at is...
http://www.coolstf.com/docs/ezftp.html
and its free!
Quote:

>I have been trying a few ActiveX FTP controls
>like http://www.mabry.com/ftp/ The problem with most things written for VB
>is that the are very event driven. This one can be run in synchronous mode.
>It can also get directory listings etc.
>Sample code...

>On Error Resume Next
>set mFTP1 = createObject("Mabry.FtpCtrl")
>mFTP1.Blocking = True 'Synchronous mode
>mFTP1.LogonName = "anonomous"
>mFTP1.LogonPassword = "password"
>mFTP1.Host = "ftp.microsoft.com"
>mFTP1.Connect
>if Err.Number=0 Then
>    mFTP1.SrcFilename = "filename.ext"
>    mFTP1.DstFilename = "C:\temp\filename.ext"
>    mFTP1.GetFile
>    If Err.Number <> 0 then
>     WshShell.popup "Failed to copy file"
>    End If
>mFTP1.Disconnect
>Else
>    WshShell.popup "Failed to connect to server"
>End If

>Ian Morrish
>WSH FAQ http://wsh.glazier.co.nz
>Home page http://www.glazier.co.nz
>NetMeeting http://ils.glazier.co.nz


>>Maybe there's a better way, but here's what works for me:

>>    Option Explicit
>>    Const vbMinimizedNoFocus = 6

>>    Dim WshShell
>>    Dim Result
>>    Dim rc

>>    rc = MsgBox("Upload?", vbOKCancel + vbInformation, "Upload...")

>>    if rc = vbCancel then
>>       WScript.Quit
>>    end if

>>    Set WshShell = WScript.CreateObject("WScript.Shell")

>>    Result = WshShell.Run("cmd /c ftp.exe -s:d:\projects\upload.scr >
>>d:projects\upload.results", vbMinimizedNoFocus, True)

>>In your 'upload.scr' file, just put the commands you want to pass to
>>ftp.exe, eg.

>>open ftp.mydomain.com
>>myuserid
>>mypassword
>>cd ftp/mydirectory
>>put myfile.exe
>>bye

>>HTH

>>Steve
>>http://www.pegasustools.com

>>>Is there away to automate ftping a file with wsh ? I am sure it
>>>is simple....

>>>thanks,
>>>scott



Wed, 07 Mar 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ftping from an asp page

2. => Connecting, FTPing and executing a web page.

3. DevStudio through JS/WSH and VBS/WSH

4. WSH calls VBA or VBA calls WSH

5. BUG in WSH 5.6 install if Wscript.exe is running while updating WSH

6. WSH project editor - also ADO definitions from WSH

7. WSH Shell RegRead, On Error, and WishList for WSH

8. WSH Beta 2 extension .ws / .wsh

9. WSH and VB class: WSH error by pressing ctrl-C

10. after installing WSH on NT4, WSH won`t work

11. BUG in WSH 5.6 install if Wscript.exe is running while updating WSH

12. Can wsh be ran at the server for clients PC's without wsh

 

 
Powered by phpBB® Forum Software