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.
Asked
Active
Viewed 9,929 times
2 Answers
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:

Daniel N
- 419
- 8
- 20
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.

Paul Hunt
- 3,395
- 2
- 24
- 39
-
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) – user1234 Jan 30 '12 at 17:13
-
I'm no c++ expert but I would imagine that using the return function is the way to specify the exit code – Paul Hunt Jan 30 '12 at 19:50
-
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 out – user1234 Jan 31 '12 at 05:35
-
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 `ExecWait` – Seki Jan 31 '12 at 09:07