Execute-Process and invalid path

I have a situation where it’s possible this package may run multiple times and I would like PSADT to ignore any errors, including if the path doesn’t exist. With the command below, the script is existing with code 60002 or 60001.


  1. The log state the path is valid, which it is not.
  2. I’m OK with using Test-Path before the command, but just wondering is I’m missing something.

Execute-Process -Path "$envWINDIR\CCMSetup\CCMSetup.exe" -Parameters "/Uninstall" -ContinueOnError $true

[Pre-Installation] :: [C:\WINDOWS\CCMSetup\CCMSetup.exe] is a valid fully qualified path, continue.
[Pre-Installation] :: Function failed, setting exit code to [60002].
Error Record:

Message : File [C:\WINDOWS\CCMSetup\CCMSetup.exe] not found.
InnerException :

FullyQualifiedErrorId : File [C:\WINDOWS\CCMSetup\CCMSetup.exe] not found.

PositionMessage :
At C:\CCMClient\AppDeployToolkit\AppDeployToolkitMain.ps1:262
4 char:11
+ Throw <<<< “File [$Path] not found.”

[Pre-Installation] :: Close the installation progress dialog.

Hi Brian,
You’re absolutely right. The check for the existence of the file part of Execute-Process is not encapsualted by the ContinueOnError Parameter.

In order to get the functionality you need you’ll need to use a test-path before running the execute-process function.

We’ll consider modifying the way Execute-process handles this error. Normally I’d just go ahead and make the change, but since this is such a critical function, we’ll need to map out the implications.

I’ve submitted this as a enhancment request to our github, you can follow that here:

The log stating that it’s a valid, fully qualified path does not mean that the file exists. It just means that the path that was provided is properly formatted, fully qualified, path that Windows would recognize. I don’t think it’s a good idea to ignore an error thrown by this function because the file does not exist. If you’re not sure whether a file you wish to execute will be present, it’s rather trivial to use Test-Path to work around the issue. If you don’t want to use Test-Path, then you can use a Try/Catch to trap the error and ignore it.
Try {
Catch {