카테고리 없음
FTP 파일 업로드 자동화 VBScript
냐옹이.
2012. 3. 31. 22:26
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim command(4)
' Chr(34) - 더블쿼테이션마크
command(0) = "open 117.16.14.27"
command(1) = "anonymous"
command(2) = "none@gmail.com"
command(3) = "put " & Chr(34) & "사유서 제출자명단.hwp" & Chr(34)
command(4) = "quit"
strTmpPath = objShell.ExpandEnvironmentStrings("%TEMP%")
strFile = strTmpPath & "\ftpput.txt"
strResultFile = strTmpPath & "\ftpResult.txt"
'If objFSO.FileExists(strFile) Then
' msgBox "File Exists"
'End If
Set objFile = objFSO.CreateTextFile(strFile, True)
For Each cmd In command
objFile.WriteLine(cmd)
Next
objShell.Run "%comspec% /c ftp -s:" & strFile & " > " & strResultFile, 0, True
If objFSO.FileExists(strResultFile) Then
Set objResultFile = objFSO.OpenTextFile(strResultFile, 1)
MsgBox objResultFile.ReadAll, vbInformation, "결과"
' objFSO.DeleteFile(strResultFile)
Else
MsgBox "The result file Does not exists."
End If
Set objShell = Nothing
objFile.Close