Public Sub WinSCP_Send(strFile As String, strLogin As String, strLocalDirectory As String, strRemoteDirectory As String) 'send file using WinSCP, deletes remote instance (if any) file before saving Dim strWinSCPPath As String Dim strShell As String, strDate As String strWinSCPPath = "C:\Program Files\WinSCP\WinSCP.exe" If Dir(strWinSCPPath) = "" Then strWinSCPPath = "C:\Program Files\WinSCP3\WinSCP3.exe" If Dir(strWinSCPPath) = "" Then MsgBox "Please verify that WinSCP is at C:\Program Files\WinSCP\WinSCP.exe (or, C:\Program Files\WinSCP3\WinSCP3.exe) and try again.", vbCritical, "Error: WinSCP.exe Not Available" Exit Sub End If End If strShell = Chr(34) & strWinSCPPath & Chr(34) & " " & strLogin & " /command ""rm " & strRemoteDirectory & strFile & """ ""exit""" Shell strShell strShell = Chr(34) & strWinSCPPath & Chr(34) & " " & strLogin & " /command ""put " & strLocalDirectory & strFile & " " & strRemoteDirectory & """ ""exit""" Shell strShell End Sub
The shell script follows:
"C:\Program Files\WinSCP\WinSCP.exe" user:password@server /command "put C:\Test.csv /path/" "exit"
The file is being sent to a UNIX server from a Windows desktop. I am basing this script on the Scripts page item for sending a single file. I do not understand why it seems to work for every file but the large one. I would assume the process would hang for 60 seconds or so while the transfer executes, but it only hangs for a second.
Is something wrong with my script?
Do I need to add a pause somewhere?
Preferably, I want the process to be seamless to the user, but, if I cannot get this to work she will have to use the WinSCP GUI to send this large file. Any help will be greatly appreciated. Using WinSCP 4.1.8.