0

I have the following Java code in PeopleCode to execute a batch file (which in turn executes WinSCP script file). How to get the return code?

Else if you guys have similar code in people code to transfer file. Please let me know.

Local JavaObject &runtime = GetJavaClass("java.lang.Runtime").getRuntime();
Local JavaObject &process = &runtime.exec("\\xyz\BATCH_FILE_NAME.bat");

Rest of the code.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Abhi09166
  • 1
  • 1

1 Answers1

0

Use the Process.exitValue() method:

&process.exitValue()

This will of course get you an exit code of the batch file. Whether that gets you exit code of WinSCP depends on how the batch file is implemented. You didn't show us.

In general you propagate exit code of WinSCP to exit code of batch file like:

winscp.com /ini=nul /command ...
exit /b %ERRORLEVEL%

Read also about Checking script results.

Though with such trivial batch file, it does not really make sense to use the batch file in the first place. You can execute the winscp.com (or the winscp.exe) directly from your PeopleCode.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992