Problem with Exitcode

Hello@all.

following Problem. I must set the Exit code for one Package to 1641 manually. I tried that way on

##===============================================
##
POST-INSTALLATION
##*===============================================
[string]$installPhase = ‘Post-Installation’

if ($mainExitCode -eq 0)
{
$mainExitCode = 1641
}

But if i do that the SCCM got wrong exit code (1) not the 1641 why?

Appenforce.log
Process 7176 terminated with exitcode: 1

Installation log is ok
<![LOG[[Post-Installation] :: A restart has been flagged as required.]LOG]!><time=“09:47:55.354120” date=“09-23-2015” component=“Exit-Script” context=“NT AUTHORITY\SYSTEM” type=“1” thread=“7176” file=“DonHo_NotepadPlusPlus_6.8.1_x86.ps1”>
<![LOG[[Post-Installation] :: DonHo_NotepadPlusPlus_6.8.1_x86_DE Installation completed with exit code [1641].]LOG]!><time=“09:47:55.357120” date=“09-23-2015” component=“Exit-Script” context=“NT AUTHORITY\SYSTEM” type=“1” thread=“7176” file=“DonHo_NotepadPlusPlus_6.8.1_x86.ps1”>
<![LOG[[Post-Installation] ::

I use the last 3.6.7 version. I i use the Deploy-Application.exe before the script, then all works fine.
But i cannot use the Deploy-Application.exe for each script, because we often uses other trigger exe’s like ServiceUI.exe

If you use the -File parameter of powershell.exe to launch a script, it does not return the correct exit code. It’s a bug with powershell that Microsoft will not fix. You have to use the -Command parameter if you want the correct exit code passed back to the calling process. Also, there is no reason why ServiceUI.exe could not be used to launch Deploy-Application.exe. I do that all the time.

Example of how to use -Command parameter to pass the correct exit code:

powershell.exe "-ExecutionPolicy" "ByPass" "-Command" "&{ & 'D:\Development\psappdeploytoolkit\Testing\Deploy-Application.ps1' -DeploymentType Install; Exit $LastExitCode }"

Example of chaining multiple EXEs, including ServiceUI.exe:

psexec.exe -s -i "E:\Testing\ServiceUIx86.exe" "E:\Testing\Deploy-Application.exe"

Many Thanks Muhammad! It works now. But i have another problem. When i run the installatiin wit ServiceUI.exe deployment-application.exe via SCCM (System, User logged on or not, Normal) i got always RC=4294967295. When i run manually with psexec -i -s ServiceUI.exe deployment-application.exe i got RC=0. Do you know why?

I have used the ServiceUIx64.exe may be that is the problem? Shall i use ServiceUIx86.exe?

Process 2916 terminated with exitcode: 4294967295	AppEnforce	30.09.2015 10:08:34	4520 (0x11A8)