2016-06-21 6 views
1

私はFTPサーバーからファイルをダウンロードして処理するスクリプトをVBSに書いています。ダウンロードが完了する前に、私は、ファイルの開始の適切な待ち時間の処理を設定しない場合VBS ftpのダウンロード待ち時間

path = evidenceFolder 
On Error Resume Next 
Const copyType = 16 

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

'FTP Wait Time in ms 
waitTime = 3000000 

strFTP = "ftp://" & FTPUser & ":" & FTPPass & "@" & FTPHost & FTPDir & FTPRoute 
Set objFTP = oShell.NameSpace(strFTP) 

'Download all files in folder 
If objFSO.FolderExists(path) Then 
    'Entire folder 
    Set objFolder = oShell.NameSpace(path) 
    objFolder.CopyHere objFTP.Items, copyType 
End If 
If Err.Number <> 0 Then 
    Wscript.Echo "Error: " & Err.Description & " - " & Err.Number 
End If 
'Wait for upload 
Wscript.Sleep waitTime 

:私は正常に動作しているコードのこの束を持っています。私は大きいファイルをダウンロードしなければならないので、私は待ち時間のために高い値を設定する必要があります。ダウンロードがそれほど大きくなければ、それはあまりにも長い時間待つだけです。

ダウンロードが完了するのを待っているだけで、任意かつ一定の時間ではありませんか?

ありがとう

答えて

2

最後に、私はFTPのやり方を変えることで解決しました。私はWinscpをダウンロードし、コマンドラインのftpクライアントとして使用しました。Windowsクライアントはpasiveモードを認識せず、FWの問題を生成していたからです。

Const ForWriting = 2 
Set objFso = CreateObject("Scripting.FileSystemObject") 
Set sessionFile = objFso.OpenTextFile("session.txt", ForWriting, vbTrue) 
With sessionFile 
    .WriteLine "open ftp://user:[email protected]" 
    .WriteLine "cd " & FTPDir & FTPRoute 
    .WriteLine "get *.* " & destFolder & "\" 
    .WriteLine "exit" 
    .Close 
End With 
strFTP = "tools\winscp577\winscp.com /script=session.txt" 
Set WshShell = CreateObject("WScript.Shell") 
strFTP = WshShell.ExpandEnvironmentStrings(strFTP) 
WshShell.Run strFTP,, vbTrue 
objFso.DeleteFile "session.txt", vbTrue 
関連する問題