Wait for Process to Complete Using PowerShell

# Execute the program. Change the -FilePath argument as needed. $script:exitCode = (Start-Process -FilePath `"setup.exe`" -Passthru -Wait).ExitCode; # Wait for process to complete. Use the Get-Process CmdLet to determine the name # of the process you need to wait for, then change the name of that process as # needed below. $running = $true; while( $running -eq $true ) { $running = ( ( Get-Process | where ProcessName -eq "setup").Length -gt 0); Start-Sleep -s 5 }