Skip to content
⌘ NSIS Forum Archive

ExecWait + IfErrors + exitcode

8 posts

cmgdok#

ExecWait + IfErrors + exitcode

I'm using NSIS 2.0 on Windows 2000. In my install script, I have the following code:

ClearErrors
ExecWait '"$INSTDIR\installmon.exe" ME C:\CAPTURE'
IfErrors abort_installmon
goto done
abort_installmon:
Abort "Unable to use installmon"
done:
.....

In my installmon source code, I have standard console win32 application where it calls exit(3) right after displaying a MessageBox with an error message.

MessageBox( hWnd, L"unable to run", L"Installer", MB_OK );
exit(3);

What am I missing to get ExecWait working?

Thanks,
Chris
Joost Verburg#
What is exactly the problem? Doesn't it start anything? Is the command line input not recieved?
cmgdok#
My command performs exit(3) ( displays the dialog just prior to that but IfErrors doesn't jump to abort_installmon and run Abort to quit the installer.
cmgdok#

ExecWait '"$INSTDIR\installmon.exe" CAP C:\CAPTURE' $INST_ERR
IfErrors abort_installme
StrCmp $INST_ERR 1 abort_installmon
MessageBox MB_OK|MB_ICONSTOP "This is the end of the line! $INST_ERR"
abort_installme:
MessageBox MB_OK|MB_ICONSTOP "I should be here!"
abort_installmon:
MessageBox MB_OK|MB_ICONSTOP "I am crashing!"
Abort ;
the abort_installme code is never run but the abort_installmon code is run now that I've added the


StrCmp $INST_ERR 1 label
That has allowed me to work around ExecWait and IfErrors lack of interaction.

Thanks!
iceman_k#
The IfErrors command is to handle any errors that NSIS may get while trying to run your external EXE, e.g., if it could not spawn the process, or if the EXE was not found, etc.

It will not handle the return code of your program- it cannot automatically assume that a non-zero return value is an error.
What you have done now is the correct way to trap your program specific errors.
Joost Verburg#
If the error code is nonzero and there is no variable set to recieve the error code the error flag should be set.