Search code examples
batch-filensisexit-code

Get batch script exitCode with ExecDos Plugin from NSIS


How do I get the exitCode from a batch file (as well as the output written to the DetailView window)?

From the documention:

Use 'wait' call if you want to get exit code. (/NOUNLOAD is mandatory!)

So something like this:

ExecDos::wait /NOUNLOAD /DETAILED "$INSTDIR\bin\checkJavaVersion.bat"

(I haven't dealt with specifying which window to output to yet)

How do I access the exitCode?


Solution

  • You first exec and then you wait. wait does not start the process so you cannot pass the command line to it. The documentation you linked to has an example:

    ExecDos::exec /NOUNLOAD /ASYNC "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execdos.log"
    Pop $0 # thread handle for wait
    # you can add some installation code here to execute while application is running.
    ExecDos::wait $0
    Pop $1 # return value
    MessageBox MB_OK "Exit code $1"