Topic "errorllevel not being returned"

Author Message
[View user's profile]

Joined: 2014-05-23
Posts: 3
Location: Dallas
I am having trouble getting WINSCP to pass the errorlevel back from execution. I have put in echoes after the execution that displays the errorlevel. It always displays zero. However, the log says it is a 1.


echo Running OCS FTP
start C:\"Program Files (x86)"\WinSCP\ /script=D:\FTP\Optum\OCSFTPDownload.txt /log=D:\FTP\Optum\OCSLog.txt
if errorlevel 1 goto error
goto end
echo fail
WINSCP Log.txt (13.8 KB) [Download]

Description: (none)

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24755
Location: Prague, Czechia
Why do you use start to run WinSCP? It's no used in any example on this site. Remove it.

The start launches WinSCP asynchronously not waiting for its exit. So when testing exit code, you are actually testing exit code of the previous command, the echo, that is always 0.

See also:
[View user's profile]

Joined: 2014-05-23
Posts: 3
Location: Dallas
You are absolutely correct. Problem solved!

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License