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

fflo92

I don't know why but extracting the line
ERRORLEVEL>\\censored\WinSCP\censored\sftpError.txt
into a separate line fixed the problem. Is the same if I use %ERRORLEVEL%
fflo92

Not getting errorlevel 1 from exception

Hi,

I generate the following script from external program:
open sftp://censored/
lcd \\censored\
cd /censored/IN
put *
close
exit

It is called with the following batch which is also generated from external program:
@echo off
\\censored\WinSCP\WinSCP.exe /log="\\censored\WinSCP\censored\log\WinSCP_DEV_!D_!M_!Y_!T.log" /ini=nul /script="\\censored\WinSCP\censored\scriptname.txt"
if ERRORLEVEL EQ 1 echo ERRORLEVEL>\\censored\WinSCP\censored\sftpError.txt

Both script and batch are working fine. To evaluate exception handling with the error file, I specified wrong server path on purpose in the WinSCP script. As expected, I get the following exception in my log:
(Exception) **Expected host key was not configured, use -hostkey switch.**

However, no error file is created. I've also used different approaches to try to create error file. As they have worked in the past, I am pretty sure it is not about my script but about how WinSCP throws the Errorlevel. It seems like WinSCP doesn't return Errorlevel=1. Can you tell me why is that?