12-02-2021 03:50 AM
Hello,
I want to create LabVIEW(2018) exe, and call from inbuilt SystemExec.vi.
But after exe exit I want to read return code from exe. How can I set return code in LabVIEW exe?
BR,
Aniket
12-02-2021 04:07 AM
log the return code in text file from the exe during exit and then read it
12-02-2021 04:10 AM
It is last solution I can think of. I need generic way to do it
12-02-2021 04:39 AM
It seems a very difficult task. Searching "return code" and LabVIEW executable in this forum I found this.
12-02-2021 05:33 AM
@pincpanter wrote:
It seems a very difficult task. Searching "return code" and LabVIEW executable in this forum I found this.
It depends what you mean. Causing your LabVIEW program to return an exit code to the caller directly is not an option under Windows. Windows GUI application, while they theoretically can return an exitCode from WinMain() are not really doing that in most cases.
LabVIEW explicitly always returns 0. In other platforms it does return an error code from the main() function but that is an error code that indicates serious problems in starting up the process itself or processing the message loop, not an error code that the running VI could influence.
If you need something like that you would have to do some sort of wrapper that calls your LabVIEW executable and that you can then post the desired error code to, before terminating the LabVIEW process. But that quickly turns into advanced Windows API programming and writing the wrapper in a different language like C or C#, not something most LabVIEW programmers would be comfortable to even try. And personally I consider the benefit of something like that not really worth the trouble.