![]() 'ret = wsh.Run(Command:=FTPcommand, WindowStyle:=5, WaitOnReturn:=True) '5 = show command windowĭebug.Print "Successfully downloaded " & strLocalFileĭebug. 'FTPcommand = "cmd /k ftp -n -s:" & Chr(34) & FTPcommandsFile & Chr(34) 'Or, for debugging - cmd /k keeps the command window open must close it manually to continue VBA execution Ret = wsh.Run(Command:=FTPcommand, WindowStyle:=0, WaitOnReturn:=True) '0 = hide command window Print #filenum, "get " & Chr(34) & strRemoteFile & Chr(34)įTPcommand = "cmd /c ftp -n -s:" & Chr(34) & FTPcommandsFile & Chr(34) Print #filenum, "lcd " & Chr(34) & Left(strLocalFile, InStrRev(strLocalFile, "\") - 1) & Chr(34) 'set local folder ![]() Print #filenum, "user " & strUser & " " & strPass Print #filenum, "open " & strHost & " " & lngPort Open FTPcommandsFile For Output As #filenum ".uk", 21, "mpc0001", "T5smB vbNullString Then Kill strLocalFileįTPcommandsFile = Environ("temp") & "\FTP_commands.txt" In the BAT file put: ftp.exe -s:C:WindowsSystem32test.txt destinationIP pause. ".uk", 21, "mpc0001", "T5smB<+uMCyr"įtp_Download_File "/ProductExport_mpc0001.zip", "C:\Temp\ProductExport_mpc0001.zip", _ In the text file put this: username password cd whereverYouWantToPutTheFile lcd whereverTheFileComesFrom put C:InventoryExportinventory.test (or your file path) bye. If FtpGetFileA(hConn, strRemoteFile, strLocalFile, 1, 0, FTP_TRANSFER_TYPE_UNKNOWN Or INTERNET_FLAG_RELOAD, 0) ThenįtpDownload "/ProductExport_mpc0001.zip", "C:\Users\JohnGlanville\OneDrive - MPC Embroidery\Desktop\Customers\BTCTest\ProductExport_mpc0001.zip", _ HConn = InternetConnectA(hOpen, strHost, lngPort, strUser, strPass, 1, 0, 2) HOpen = InternetOpenA("FTPGET", 1, vbNullString, vbNullString, 1) Sub FtpDownload(ByVal strRemoteFile As String, ByVal strLocalFile As String, ByVal strHost As String, ByVal lngPort As Long, ByVal strUser As String, ByVal strPass As String) Private Declare PtrSafe Function InternetCloseHandle Lib "wininet" ( _ Private Declare PtrSafe Function FtpGetFileA Lib "wininet.dll" ( _ If the selected item in the view is a file, the user can download it by pushing the Download button. A list of the servers top-level directory is then presented in the File List tree view. Private Declare PtrSafe Function InternetConnectA Lib "wininet.dll" ( _ The user of the example can enter the address or hostname of an FTP server in the Ftp Server line edit, and then push the Connect button to connect to it. ![]() Private Declare PtrSafe Function InternetOpenA Lib "wininet.dll" ( _ These options + password passtrough should be on that command line. User + password are specified in 'that' one-line cmd. Private Const INTERNET_FLAG_RELOAD As Long = &H80000000 21 I know there is an FTP command which can be run from command line on Windows, and it downloads a file from an FTP site. Private Const FTP_TRANSFER_TYPE_UNKNOWN As Long = 0
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |