execute-proces file not found

Have a script im trying to use which will uninstall all previous versions of an application, so i threw a load of statements like below in.

<code>execute-process &#039;c:\ver1\uninstall.exe&#039; -continueonerror=$true
execute-process &#039;c:\ver2\uninstall.exe&#039; -continueonerror=$true</code>

Unfortunately, if it cant find one of these versions, it bombs out saying file not found and wont continue, i thought the continue on error would resolve this, but it still fails.

Anyone got a better way of doing this, or a way of getting it to continue regardless.

I think the continueonerror is meant to be used if the process you’re trying to execute exits with a bad code.

You could use test-path in an if statement, and since you seem to have indefinite number of paths it’d be neat to place them in an array and loop through it.

Something like:

[array]$Paths = “C:\App1\unins.exe”,“C:\App2\unins.exe”,“C:\app3\unins.exe”

foreach ( $exe in $paths ) {
if ( test-path $exe ) {
execute-process -path “$exe”
}
}

worked perfect, thanks mate.