H
H
Hancog2014-11-03 18:20:45
FTP
Hancog, 2014-11-03 18:20:45

Need to edit VBS,FTP?

Option Explicit

Const SHCONTF_NONFOLDERS    = &H00040
Const SHCONTF_INCLUDEHIDDEN = &H00080


Dim arrFiles
Dim strFTPFolder

Dim objFSO
Dim objShell

Dim strFile

Dim objDestFolder

Dim lngCurrSize

Dim objFolderItems
Dim objFolderItem


arrFiles = Array( _
    "D:\Install\Mozilla Firefox\Mozilla Firefox 28.0\Firefox Setup 28.0.exe", _
    "D:\Install\Mozilla Firefox\Mozilla Firefox 28.0\FirefoxPortable_28.0_Russian.paf.exe", _
    "D:\Install\Mozilla Firefox\Mozilla Firefox 33.0.2\Firefox Setup 33.0.2.exe", _
    "D:\Install\Mozilla Firefox\Mozilla Firefox 33.0.2\FirefoxPortable_33.0.2_Russian.paf.exe" _
)

strFTPFolder = "ftp://User:[email protected]/DestFolder"


Set objFSO   = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("Shell.Application")

Set objDestFolder = objShell.NameSpace(strFTPFolder)

If Not objDestFolder Is Nothing Then
    For Each strFile In arrFiles
        If objFSO.FileExists(strFile) Then
            WScript.Echo strFile, "--->", objDestFolder.self.Path
            
            lngCurrSize = -1
            
            objDestFolder.CopyHere strFile
            
            Do Until lngCurrSize = objFSO.GetFile(strFile).Size
                Set objFolderItems = objDestFolder.Items
                
                objFolderItems.Filter SHCONTF_NONFOLDERS + SHCONTF_INCLUDEHIDDEN, "*.*"
                
                For Each objFolderItem In objFolderItems
                    If objFolderItem.Name = objFSO.GetFileName(strFile) Then
                        lngCurrSize = objFolderItem.Size
                    End If
                Next
                
                WScript.Sleep 100
                
                Set objFolderItems = Nothing
            Loop
        Else
            WScript.Echo "Can't find source file [" & strFile & "]."
        End If
    Next
Else
    WScript.Echo "Can't connect into FTP folder [" & strFTPFolder & "]."
    WScript.Quit 2
End If

Set objShell = Nothing
Set objFSO   = Nothing

WScript.Quit 0

Please tell me how to add file upload by mask to this VBS code, for example *txt

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question