@shashi.singh: See https://winscp.net/eng/docs/script_download_most_recent_file
- martin
C:\Program Files\WinSCP\WinSCP.exe /console /command "option batch on" "open user:password@server" "put C:\File.txt /serverpath/" "exit"
> 2009-04-10 06:48:57.051 Type: SSH_FXP_OPENDIR, Size: 20, Number: 1291
< 2009-04-10 06:48:57.051 Type: SSH_FXP_STATUS, Size: 24, Number: 1028
. 2009-04-10 06:48:57.051 Discarding reserved response
< 2009-04-10 06:48:57.102 Type: SSH_FXP_HANDLE, Size: 13, Number: 1291
> 2009-04-10 06:48:57.112 Type: SSH_FXP_READDIR, Size: 13, Number: 1548
< 2009-04-10 06:48:57.689 Type: SSH_FXP_NAME, Size: 9067, Number: 1548
> 2009-04-10 06:48:57.689 Type: SSH_FXP_READDIR, Size: 13, Number: 1804
< 2009-04-10 06:48:57.750 Type: SSH_FXP_STATUS, Size: 28, Number: 1804
< 2009-04-10 06:48:57.750 Status/error code: 1
> 2009-04-10 06:48:57.750 Type: SSH_FXP_CLOSE, Size: 13, Number: 2052
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
"C:\Program Files\WinSCP\WinSCP.exe" user:password@server /command "put C:\Test.csv /path/" "exit"