Post a reply

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)


Topic review


I'm sending you an email with a development version of WinSCP to the address you have used to register on this forum.

With /loglevel=1, it prints its exit code on output. Please test it, to see what WinSCP believes its exit code is.

Windows Server 2012 R2 which is similar to Windows 10. We had a host blocking our ip which is when we noticed this. Otherwise yes it works fine on failed logins, etc.. weird. Thanks for looking into it

Log file looks all good. And I cannot reproduce your problem. It works just fine for me with your batch file. What version of Windows are you using?

Did the log file help any? We aren't sure how to resolve this issue.

Hello Martin, I've attached a log for your review. Thanks

Re: Connection failed not returning an error code

Please attach a log file.

Connection failed not returning an error code

I don't seem to getting an error code when the SFTP connection fails. (Server blocked me)
Script seems to work find otherwise - for example bad password etc.

Can someone please help me catch this error so that if it doesn't connect the batch file sees the error code.

# start script code 

open s
option transfer binary
cd pim
put \\Shares\Web\ItemUpdated\*.xml -preservetime

"C:\Program Files (x86)\WinSCP\" /console /script=C:\my_script.txt /log="C:\FileUpload\log\transfer.log" /logsize=5*10M

if %ERRORLEVEL% neq 0 goto error
echo Upload succeeded, moving local files to archive
move \\Shares\Web\ItemUpdated\*.xml \\Shares\Web\ItemProcessed
echo Removing any archive files older than 30 days
FORFILES /p "\\Shares\Web\ItemProcessed" /d -30 /m *.xml /c "cmd /c del @file"
exit 0

echo Upload failed, keeping local files
exit 1