Created
July 17, 2020 07:39
-
-
Save swt02026/ab51bbcbd006e2043c4ad9189bdc9f26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $language = "VBScript" | |
# $interface = "1.0" | |
Class FtpLoginInfo | |
Public userName | |
Public password | |
Public serverIp | |
Public Default Function Init(un, pw, ip) | |
userName = un | |
password = pw | |
serverIp = ip | |
Set Init = Me | |
End Function | |
End Class | |
Function GetFtpScript(userName, password, fileName) | |
ftpScript = "USER " & userName & vbCRLF | |
ftpScript = ftpScript & password & vbCRLF | |
ftpScript = ftpScript & "binary" & vbCRLF | |
ftpScript = ftpScript & "put " & fileName & vbCRLF | |
ftpScript = ftpScript & "quit" & vbCRLF | |
GetFtpScript= ftpScript | |
End Function | |
Sub WriteFtpScriptFile(userName, password, fileName, ftpScriptFile) | |
ftpScript = GetFtpScript(userName, password, fileName) | |
ftpScriptFile.WriteLine(ftpScript) | |
ftpScriptFile.Close | |
Set ftpScriptFile = Nothing | |
End Sub | |
Sub UploadFile(ftpLoginObject, fileName) | |
userName = ftpLoginObject.userName | |
password = ftpLoginObject.password | |
host = ftpLoginObject.serverIp | |
Set myShell = CreateObject("WScript.Shell") | |
Set ftpScriptFSO = CreateObject("Scripting.FileSystemObject") | |
ftpTempFolder = myShell.ExpandEnvironmentStrings("%TEMP%") | |
ftpTempFullName = ftpTempFolder & "\" & ftpScriptFSO.GetTempName | |
Set ftpScriptFile = ftpScriptFSO.CreateTextFile(ftpTempFullName, True) | |
WriteFtpScriptFile userName, password, fileName, ftpScriptFile | |
myShell.Run "%comspec% /c ftp -n -s:" & ftpTempFullName & " " & host | |
End Sub | |
Sub Main() | |
Dim infos | |
loginInfos = Array( _ | |
(New FtpLoginInfo)("", "", "") _ | |
) | |
For Each loginInfo In loginInfos | |
UploadFile loginInfo, crt.Session.LogFileName | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment