1

I am trying to use WinSCP to automate some basic FTP tasks so I have downloaded and setup the latest WinSCP 5.7.7 however I keep getting the following error when trying to execute the .bat with the script I have created. I am running Windows 10 Pro 1511

Error I get from running the .bat file.

Unknown command 'winscp.com'.


ftp.bat

winscp.com /script="C:\AutoRun\ftp-script.txt" 

pause

ftp-script.txt

winscp.com /log=ftp.log /command ^ 
    "open ftp://user:pass@url.com/" ^ 
    "put -latest C:\Users\Dan\Documents\Test\* / 
    "exit"
2
  • 1
    Either use the full path to winscp.com or add the appropriate directory to the system PATH.
    – DavidPostill
    Jun 8 '16 at 11:31
  • @DavidPostill The "Unknown command" in WinSCP error message. It's not the Windows "'winscp.com' is not recognized as an internal or external command, operable program or batch file." error message. Jun 8 '16 at 11:57
2

You are trying to run winscp.com from winscp.com. WinSCP obviously does not recognize the winscp.com as its command.


Your ftp-script.txt is not a WinSCP script, it's actually a Windows batch file.

  • Delete your ftp.bat.
  • Rename the ftp-script.txt to ftp.bat.
  • Append pause to its end.
  • And run it.

Then you will hit second issue, that you are missing a double-quote and a caret after the put -latest C:\Users\Dan\Documents\Test\* /:

winscp.com /log=ftp.log /command ^ 
    "open ftp://user:pass@url.com/" ^ 
    "put -latest C:\Users\Dan\Documents\Test\* /" ^
    "exit"

Then you will hit third issue, that the -latest switch is supported by the WinSCP 5.8.x only, not by 5.7.7 (the latest 5.8.3 in release candidate).


See also WinSCP FAQ Why are some WinSCP scripting commands specified in a batch file not executed/failing?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.