Post a reply

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

Menowing

Re: winscp in batch file - exit code issue

martin wrote:

You have to move set WINSCP_RESULT=%ERRORLEVEL% after the call to WinSCP.


Hi
I moved it. After the upload, the script is "hanging" and it is showing the console. By manually entering an exit command it is sending the e-mail, not sure why the console window stays open.
martin

Re: winscp in batch file - exit code issue

You have to move set WINSCP_RESULT=%ERRORLEVEL% after the call to WinSCP.
Menowing

winscp in batch file - exit code issue

Hi
I have an issue with my batch script. The upload is working fine, the part with the exit code not.

Any help much appreciated.

******************************************************************************************

@echo off


set WINSCP_RESULT=%ERRORLEVEL%

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\mydirectory\local\WinSCP.log" /ini=nul ^
/command ^
"open sftp://username:password@sftp.remoteserver.com/ -hostkey=""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=""" ^
"lcd c:\mydirectory\local" ^
"cd upload" ^
"put *.xls" ^
"mv *.xls *.zip" ^
"exit"


if %WINSCP_RESULT% equ 0 (
C:\mydirectory\local\blat.exe -body "successfull" -from my@domain.com -to me@domain.com -subject "successfull" -server my.smtp.com:25
) else (
C:\mydirectory\local\blat.exe -body "failed" -from my@domain.com -to me@domain.com -subject "failed" -server my.smtp.com:25
)

exit /b %WINSCP_RESULT%

******************************************************************************************