how to get the exit code of other application in nsis
Asked Answered
D

2

8

In my .nsi file I am calling ExecWait '"$INSTDIR\application.exe" ' $0 . In application.exe I am returning exit codes for success and failures. How to catch those exit codes in .nsi file.

Derogatory answered 30/1, 2012 at 10:35 Comment(0)
E
12

If there is an error performing ExecWait, then the contents of the user variable passed in is undefined.

To simply check if the program executed correctly or not, check the error flag. (btw, NSIS expects zero for success and non-zero for error)

ClearErrors
ExecWait '"$INSTDIR\application.exe"'
IfErrors 0 noError
; Handle error here
noError:
Enure answered 2/2, 2012 at 16:37 Comment(0)
E
5

The exit code of the application will be stored in the variable that is passed as the 2nd argument to ExecWait, so $0 in your example.

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.4

Ecbolic answered 30/1, 2012 at 11:25 Comment(4)
i am passing integer 1 as success and integer 2 as failure, but when i I execute above ExecWait code, I am always getting 0 as its value. Can u please tel me how should I send return value in application (C++ code)Derogatory
I'm no c++ expert but I would imagine that using the return function is the way to specify the exit codeEcbolic
i need not know exactly in C++, any other programming language also ok. I am returning error code from function of my application. I call that application in my .nsi file but not getting the error code which I am sending. Please help me outDerogatory
Could you paste an excerpt of the main() of your c++ program ? Basically, at the end of the code, if you put a return 42; that 42 value should be catched in the variable that you give to ExecWaitCalcific

© 2022 - 2024 — McMap. All rights reserved.