First time using WinSCP and relatively new to scripting as well. Have developed a script that connects to the SFTP I need and downloads the latest text file but for some reason it doesn't exit from WinSCP so my Command Prompt window stays open after the script has run. I am using WinSCP version 5.17.5 on Windows 10.
The following is the bat file (with personal directory names and passwords removed):
cd C:\Program Files (x86)\WinSCP\ WinSCP.com /open MyConnectionName /passphrase=MyPassPhrase ^ /command ^ "option batch off" ^ "option confirm on" ^ "lcd C:\Users\MyDirectory\Downloads" ^ "get -latest *.txt" ^ "exit"
Attached is a screenshot of what happens on the Command Prompt window. I've also attached the batch file as well.