As soon as I get to Start-Process, it will create a Office-Click-to-Run process while installing Office. I want to remove the $uncDestination as soon as the Office-Click-to-Run process terminates. If there is a method to rather run the batch command in Powershell, I can add a -Wait command.
#Infinite wait
Start-Process -FilePath "$uncDestination\setup.exe" -ArgumentList '/configure configuration-64.xml' -Wait
#Or
#Wait with specific timeout
$TimeOut = 900
$Process = Start-Process -FilePath "$uncDestination\setup.exe" -ArgumentList '/configure configuration-64.xml' -PassThru
$Process | Wait-Process -TimeOut $TimeOut
if($Process.HasExited){
# $Process.ExitCode will give you the exit ode, you check and decide what to do
}
else{
Throw "Process didn't complete in $TimeOut seconds"
}
I would recommend you to go through the help documentation of Start-Process cmdlet, Get-Help Start-Process -Full