I have an installer written in WIX, that has a WPF Bootstrapper. Recently we added a silent installation mode, and we need to use return codes in order to specify what kind of error occurred during silent installation, for instance: invalid username or password, incorrect server address, unsupported Windows version, etc.
We use the Engine.Quit() method from Bootstrapper class to exit the installer with an exit code. This exit code can be seen in the installer log:
[5490:4F84][2018-09-14T14:31:03]i007: Exit code: 0x101, restarting: No
However, when I check the %errorlevel% environment variable, it remains unchanged. Using Environment.Exit() did not help either.
I suspected, that MSI might be responsible for such behavior by overwriting what WIX tried to set, but even forcing ActionResult.Failure in one of the actions of installer does not help. The MSI exit code is in the MSI log, but %errorlevel% remains unchanged:
MSI (c) (AC:9C) [14:30:59:133]: MainEngineThread is returning 1603
=== Verbose logging stopped: 2018-09-14 14:30:59 ===
Is it possibe to make WIX set the %errorlevel% to a custom value, and if yes, how can it be done?