BAT Script opens Session, No Commands

Advertisement

grafix23
Joined:
Posts:
2

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%

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
35,438
Location:
Prague, Czechia

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.

Reply with quote

Advertisement

You can post new topics in this forum