IgnoreExitCodes not working

For my pre-installation task I have the following:

Execute-Process -Path 'C:\Program Files (x86)\LansweeperAgent\uninstall.exe' -Parameters '--mode unattended' -IgnoreExitCodes *

I also tried:

Execute-Process -Path 'C:\Program Files (x86)\LansweeperAgent\uninstall.exe' -Parameters '--mode unattended' -IgnoreExitCodes '60002'

But for some reason it’s still not moving past that… See below…

[Pre-Installation] :: [C:\Program Files (x86)\LansweeperAgent\uninstall.exe] is a valid fully qualified path, continue.	Execute-Process	10/22/2020 4:58:37 PM	1104 (0x0450)
[Pre-Installation] :: Function failed, setting exit code to [60002]. 
Error Record:
-------------

Message        : File [C:\Program Files (x86)\LansweeperAgent\uninstall.exe] 
                 not found.
InnerException : 

FullyQualifiedErrorId : File [C:\Program Files 
                        (x86)\LansweeperAgent\uninstall.exe] not found.
ScriptStackTrace      : at Execute-Process<Process>, C:\windows\ccmcache\1d\App
                        DeployToolkit\AppDeployToolkitMain.ps1: line 2791
                        at <ScriptBlock>, 
                        C:\windows\ccmcache\1d\Deploy-Application.ps1: line 129
                        at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At C:\windows\ccmcache\1d\AppDeployToolkit\AppDeployToolkitMa
                  in.ps1:2791 char:6
                  +                     Throw "File [$Path] not found."
                  +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



	Execute-Process	10/22/2020 4:58:37 PM	1104 (0x0450)
[Pre-Installation] :: Lansweeper_LSAgent_7.2.110.118_EN_01 Installation completed with exit code [60002].	Exit-Script	10/22/2020 4:58:37 PM	1104 (0x0450)
[Pre-Installation] :: -------------------------------------------------------------------------------	Exit-Script	10/22/2020 4:58:37 PM	1104 (0x0450)

Well thats because your .exe didnt return exit code because it wasnt even started because it wasnt found.

Thanks… Do you know what code I would put in the pre-uninstall so if the exe is found, it uninstalls it, if not, it just goes to the install portion?

if (Test-Path -Path 'C:\Program Files (x86)\LansweeperAgent\uninstall.exe' -PathType Leaf) {
    Write-Log "Previous version detected - uninstalling..."
    Execute-Process -Path 'C:\Program Files (x86)\LansweeperAgent\uninstall.exe' -Parameters '--mode unattended' -IgnoreExitCodes *
}
1 Like

So I’m still having issues… I’m getting a different error now, see below… This is my install string:

## <Perform Pre-Installation tasks here>
		if (Test-Path -Path 'C:\Program Files (x86)\LansweeperAgent\uninstall.exe' -PathType Leaf) {
		Write-Log "Previous version detected - uninstalling..."
		Execute-Process -Path 'C:\Program Files (x86)\LansweeperAgent\uninstall.exe' -Parameters '--mode unattended' -IgnoreExitCodes  *
		}
[Pre-Installation] :: Function failed, setting exit code to [60002]. 
Error Record:
-------------

Message        : Exception calling "Start" with "0" argument(s): "The specified executable is not a valid application 
                 for this OS platform."
InnerException : System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid 
                 application for this OS platform.
                    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
                    at CallSite.Target(Closure , CallSite , Object )

FullyQualifiedErrorId : Win32Exception
ScriptStackTrace      : at Execute-Process<Process>, C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                        line 3131
                        at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 128
                        at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3131 char:5
                  +                 $null = $process.Start()
                  +                 ~~~~~~~~~~~~~~~~~~~~~~~~



Error Inner Exception(s):
-------------------------

Message        : The specified executable is not a valid application for this OS platform.
InnerException : 



	Execute-Process	11/16/2020 10:43:13 PM	14308 (0x37E4)
[Pre-Installation] :: Error Record:
-------------

Message        : Function failed, setting exit code to [60002]. 
                 Error Record:
                 -------------
                 
                 Message        : Exception calling "Start" with "0" argument(s): "The specified executable is not a 
                 valid application 
                                  for this OS platform."
                 InnerException : System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a 
                 valid 
                                  application for this OS platform.
                                     at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
                                     at CallSite.Target(Closure , CallSite , Object )
                 
                 FullyQualifiedErrorId : Win32Exception
                 ScriptStackTrace      : at Execute-Process<Process>, 
                 C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                                         line 3131
                                         at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 128
                                         at <ScriptBlock>, <No file>: line 1
                                         at <ScriptBlock>, <No file>: line 1
                 
                 PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3131 char:5
                                   +                 $null = $process.Start()
                                   +                 ~~~~~~~~~~~~~~~~~~~~~~~~
                 
                 
                 
                 Error Inner Exception(s):
                 -------------------------
                 
                 Message        : The specified executable is not a valid application for this OS platform.
                 InnerException : 
                 
                 
                 
                 
InnerException : 

FullyQualifiedErrorId : Function failed, setting exit code to [60002]. 
                        Error Record:
                        -------------
                        
                        Message        : Exception calling "Start" with "0" argument(s): "The specified executable is 
                        not a valid application 
                                         for this OS platform."
                        InnerException : System.ComponentModel.Win32Exception (0x80004005): The specified executable 
                        is not a valid 
                                         application for this OS platform.
                                            at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo 
                        startInfo)
                                            at CallSite.Target(Closure , CallSite , Object )
                        
                        FullyQualifiedErrorId : Win32Exception
                        ScriptStackTrace      : at Execute-Process<Process>, 
                        C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                                                line 3131
                                                at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 
                        128
                                                at <ScriptBlock>, <No file>: line 1
                                                at <ScriptBlock>, <No file>: line 1
                        
                        PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3131 
                        char:5
                                          +                 $null = $process.Start()
                                          +                 ~~~~~~~~~~~~~~~~~~~~~~~~
                        
                        
                        
                        Error Inner Exception(s):
                        -------------------------
                        
                        Message        : The specified executable is not a valid application for this OS platform.
                        InnerException : 
                        
                        
                        
                        
ScriptStackTrace      : at Execute-Process<Process>, C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                        line 3278
                        at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 128
                        at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3278 char:6
                  + ...             Throw "Function failed, setting exit code to [$returnCode ...
                  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



	Deploy Application	11/16/2020 10:43:13 PM	14308 (0x37E4)
[Pre-Installation] :: Bypassing Dialog Box [Mode: NonInteractive]: Error Record:
-------------

Message        : Function failed, setting exit code to [60002]. 
                 Error Record:
                 -------------
                 
                 Message        : Exception calling "Start" with "0" argument(s): "The specified executable is not a 
                 valid application 
                                  for this OS platform."
                 InnerException : System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a 
                 valid 
                                  application for this OS platform.
                                     at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
                                     at CallSite.Target(Closure , CallSite , Object )
                 
                 FullyQualifiedErrorId : Win32Exception
                 ScriptStackTrace      : at Execute-Process<Process>, 
                 C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                                         line 3131
                                         at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 128
                                         at <ScriptBlock>, <No file>: line 1
                                         at <ScriptBlock>, <No file>: line 1
                 
                 PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3131 char:5
                                   +                 $null = $process.Start()
                                   +                 ~~~~~~~~~~~~~~~~~~~~~~~~
                 
                 
                 
                 Error Inner Exception(s):
                 -------------------------
                 
                 Message        : The specified executable is not a valid application for this OS platform.
                 InnerException : 
                 
                 
                 
                 
InnerException : 

FullyQualifiedErrorId : Function failed, setting exit code to [60002]. 
                        Error Record:
                        -------------
                        
                        Message        : Exception calling "Start" with "0" argument(s): "The specified executable is 
                        not a valid application 
                                         for this OS platform."
                        InnerException : System.ComponentModel.Win32Exception (0x80004005): The specified executable 
                        is not a valid 
                                         application for this OS platform.
                                            at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo 
                        startInfo)
                                            at CallSite.Target(Closure , CallSite , Object )
                        
                        FullyQualifiedErrorId : Win32Exception
                        ScriptStackTrace      : at Execute-Process<Process>, 
                        C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                                                line 3131
                                                at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 
                        128
                                                at <ScriptBlock>, <No file>: line 1
                                                at <ScriptBlock>, <No file>: line 1
                        
                        PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3131 
                        char:5
                                          +                 $null = $process.Start()
                                          +                 ~~~~~~~~~~~~~~~~~~~~~~~~
                        
                        
                        
                        Error Inner Exception(s):
                        -------------------------
                        
                        Message        : The specified executable is not a valid application for this OS platform.
                        InnerException : 
                        
                        
                        
                        
ScriptStackTrace      : at Execute-Process<Process>, C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1: 
                        line 3278
                        at <ScriptBlock>, C:\WINDOWS\ccmcache\4w\Deploy-Application.ps1: line 128
                        at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At C:\WINDOWS\ccmcache\4w\AppDeployToolkit\AppDeployToolkitMain.ps1:3278 char:6
                  + ...             Throw "Function failed, setting exit code to [$returnCode ...
                  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



...	Show-DialogBox	11/16/2020 10:43:13 PM	14308 (0x37E4)

Not really a toolkit error. Windows(net framework) does not like your uninstall.exe file.

OK, thanks… But why is the toolkit not ignoring the error and continuing?