Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: BAT Script opens Session, No Commands

I've tested your script and it works for me.
But maybe some tiny detail got lost while posting the code.
Check this article:
https://winscp.net/eng/docs/faq_batch_file
(particularly the "New-line Escaping" section)
If this does not help, post a session log file and exact transcript (or screenshot) of the console window.
grafix23

BAT Script opens Session, No Commands

This used to run with no issue on versions of Windows Server prior to 2016. Now, it will execute, but leave open a command prompt with an active WinSCP session waiting for the commands. Eventually the session times out with no action.

Any ideas?
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\logs\WinSCP\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://***:***@ftp.***.org/ -hostkey=""ssh-rsa 2048 ***""" ^
    "lcd ""C:\LocalFolder""" ^
    "cd /remoteFolder" ^
    "get -delete myfile.csv" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%