The command I am running is: (I am purposely specifying a file which does not exists to get the error code)
c:\winscp.com /console /command "option batch abort" "option confirm off" "open ftp://[hiddenFTPdetails]" "put c:\work\test3.txt" "exit" & ECHO errorcode=%ERRORLEVEL%
The following gets returned?
batch abort confirm off Connecting to ftp://[hiddenFTPdetails] ... Connected with ftp://[hiddenFTPdetails] Waiting for welcome message... Connected Starting the session... Reading remote directory... Session started. Active session:  ftp://[hiddenFTPdetails] File or folder 'c:\work\test3.txt' does not exist. System Error. Code: 2. The system cannot find the file specified (A)bort, (R)etry, (S)kip, Ski(p) all: Abort errorcode=0 NULL
As you can see the System Error code is being returned correctly but the errorlevel (System Error. Code: 2.) being read back to SQL is 0 (errorcode=0) - how do i echo the system error code