Search code examples
c++windowsnsis

NSIS: How ExecWait handles exe's that otherwise crash


I have an exe that needs VC++ environment to run and otherwise crashes.

If I run it in non VC++ environment, from command line or from C++ code CreateProcess function, it obviously gets crashed and system error message is shown like below

enter image description here

But when I am executing it from ExecWait in NSIS script, its just executing it. The exe must still be crashing but its not showing any error messages.

If I'm right ExecWait as well uses CreateProcess function internally. Then why this difference?

Is there any flag in CreateProcess Function that needs to be passed to get this behavior?


Solution

  • NSIS does not pass any special flags:

    StartUp.cb=sizeof(StartUp);
    if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &StartUp, &ProcInfo)) ...
    

    but before it gets to this point it does SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); which might affect things.

    The other thing to remember is that a SetOutPath instruction in a NSIS script also changes the process working directory so if you set it to a path where those dll's exist the child process should pick them up as well...