Script ERRORLEVEL not working as expexted

Advertisement

ericcao
Joined:
Posts:
1
Location:
canada

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!

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum