Retrying Script/Connection Attempt

The following batch file retries failed script after set interval. You can use it, when the server tends to be temporarily unavailable (WinSCP does not retry an initial connection attempt automatically).

@echo off
set TRIES=3
set INTERVAL=10
 
:retry
 
winscp.com /script=script.txt
 
if %ERRORLEVEL% neq 0 (
   set /A TRIES=%TRIES%-1
   if %TRIES% gtr 1 (
       echo Failed, retrying in %INTERVAL% seconds...
       timeout /t %INTERVAL%
       goto retry
   ) else (
       echo Failed, aborting
       exit /b 1
   )
)
 
echo Success
exit /b 0

Further Reading

 
  script_retry.txt · Last modified: by martin
 

Search Documentation

This page

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

Associations

Site design by Black Gate