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: Script ERRORLEVEL not working as expexted

Please attach a full session log file showing the problem (using the latest version of WinSCP).

Btw, you should be using WinSCP.com (not .exe) from the batch file.
https://winscp.net/eng/docs/executables
ericcao

Script ERRORLEVEL not working as expexted

Hi,

We are trying to transfer some files to client FTP server and it needs to stop transfer whenever it detects an error (client FTP server is not stable).

We use a batch script like this:
cd /d %~dp0
".\WinSCP\WinSCP.exe" /script=.\FTP_Outbound.txt /log=.\FTP_Outbound_log.txt /logsize=5*10M
if %ERRORLEVEL% NEQ 0 (
    echo WinSCP transfer failed. Files will not be moved.
    exit /b %ERRORLEVEL%
)
cd /d D:\Exports\
rem Move files to Backup folder:
move /Y *.* Backup

We are trying to exit the script completely if the ERRORLEVEL is not equal to 0 but it never work as expected. Please advise.

In the logs we can see errors like
Timeout detected. (control connection)
Connection failed.

which might not return as ERRORLEVEL other than 0 I assume?

Thanks and appreciate your help!