Re: Error Code always 0
Thank you Martin, this did it!
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
"option failonnomatch on" ^
"put -nopreservetime -nopermissions D:\aews\maintenance.application\export\*.fil" ^
%ERRORLEVEL%
in your WinSCP commandline will be expanded by Windows command interpreter before it even runs WinSCP. You you will always get 0
there.
set WINSCP_RESULT=%ERRORLEVEL%
ECHO ERRORLEVEL %WINSCP_RESULT%
@echo off
"D:\temp\WinSCP\WinSCP.com" ^
/log="D:\temp\winscp\WinSCP.log" /ini=nul ^
/command ^
"open sftp://CM111XXXSI:XxXXxXXX@QAFILEXMIT:10088/ -hostkey=""ssh-rsa 2048 *****************************************"" -privatekey=""D:\certificate\e*********.ppk"" -passphrase=""***********"" -rawsettings AuthKI=0 GSSAPIFwdTGT=1 KEX=""rsa,ecdh,dh-gex-sha1,dh-group14-sha1,WARN,dh-group1-sha1""" ^
"put -nopreservetime -nopermissions D:\aews\maintenance.application\export\*.fil" ^
"ECHO ERRORLEVEL %ERRORLEVEL%" ^
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT%
d:\escrow\jobs>filetransfer
Searching for host...
Connecting to host...
Authenticating...
Using username "CM111XXXSI".
Authenticating with public key "*******".
Further authentication required
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] CM111XXXSI@*********
No file matching '*.fil' found.
ERRORLEVEL 0
Success