I am trying to download a file using WinSCP from a .bat
file. I have the connection working now, but it keeps erroring out with the unknown command ^
.
Any ideas how to resolve this?
Here is my code:
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\temp\WinSCP.log" /ini=nul ^
/command ^
"open sftp://un:pw@sftp.site.com/ -hostkey=""*"" -privatekey=""C:\Location\To\Private.ppk""" ^
"cd /" ^
"lcd C:\temp\LatestFile" ^
"get -latest Filename*" ^
"exit"
I'm not getting the error you mentioned with your batch file. In any case, your batch file has wrong syntax. The continuation lines should be indented:
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\temp\WinSCP.log" /ini=nul ^
/command ^
"open sftp://un:pw@sftp.site.com/ -hostkey=""*"" -privatekey=""C:\Location\To\Private.ppk""" ^
"cd /" ^
"lcd C:\temp\LatestFile" ^
"get -latest Filename*" ^
"exit"
See https://winscp.net/eng/docs/faq_batch_file#newline_escaping