Per WillReboot if you use OnRequest
and the return code is not 0-2
then "The command failed. An error must be returned and installation terminated.".
Apparently this works with both "specialize
" and "auditUser
". If defined and configured properly, this should terminate the installation as it says this option does.
If the value of WillReboot
is OnRequest
, the synchronous command must return one of the following codes.
- Return code:
0
- Description: The command was successful. No reboot is required.
- Return code:
1
- Description: The command was successful. An immediate reboot is required. Then, the next command can be started.
- Return code:
2
- Description: The command is still in process. An immediate reboot is required. Then, the same command must be restarted. This
code can be returned multiple times.
- Return code:
<anything else>
- Description: The command failed. An error must be returned and installation terminated.
Source
Other useful detail
I would also add that a command within Path
element that calls
powershell.exe scriptfile.ps1
may end up abstracting exit codes from
script file. In my case, even though the script ends with Exit 10
,
the ending %errorlevel%
value was still 1
, as in "Powershell did
not exit with a 0
". To work around this, I modified the command to
'powershell -command "& ./scriptfile.ps1;exit $LASTEXITCODE;"'
. –
Crono
Exceptions
Furthermore, for unhandled exception capturing (or triggering one), I find the Try{}Catch{} useful most of the time. For example $e=try{<logic>}Catch{$False}; If(!$e){$FreakOut=$True}
or some variation as such to help trigger one if it isn't otherwise by the executing process.
If all else fails and you need to capture everything you can't see the output on at runtime, incorporate start-transcript and inspect its log after the execution run being troubleshot.
Supporting Resources