Application prevents installer from returning Exit

2019-06-13 18:55发布

问题:

Got weird problem. I have installer, which works just fine. I'm launching it with PowerShell, something like

$p = 'Start-Process $path -Verb "RunAs" -PassThru -Wait'
$p = Invoke-Expression $p

and getting its exit code as $p.ExitCode Usually it all works perfect. But I've added ShellExec in CurStepChanged, for ssPostInstall step, to launch additional executable after installation finish.

ShellExec('', ExpandConstant('{app}\DentalDesktopServerAgent.exe'), '', '', SW_HIDE, ewNoWait, ResultCode);

And with this, it does no longer return exit code. This line is the only difference between installer with and without exit code. And since PowerShell script is waiting for exit code, it simply hangs.

So, why does ShellExec impact exit code? Any ideas?

Update: It seems, problem is not in ShellExec, but in launched application itself. Application itself is not supposed to be closed (it is helper application for main installed application). I've tried to move it to [Run], and it seems, that application does not return exit code (thats obvious). But I'm not sure, that this causes installer to not return its own exit code, since even after moving launching of application to bat file, when bat file returns exit code right after application was started, installer still does not return exit code, although all its [Run] entry do.

Update: Additional info incoming. Logged result code of Exec, which launches application. Code is 259, which means "application still in progress". Is it possible, that it impacts result code of installer?

回答1:

I did not read your question very well yesterday. It seems it is the Invoke-Expression that is giving you trouble. Try launching your installer the normal way (by just stating its path as in a batch file) and then check PowerShell variable $LastExitCode.

I assume you know what exit codes to compare to: http://www.jrsoftware.org/ishelp/index.php?topic=setupexitcodes