powerShell: Start-Process -Wait sometimes does not return although child process exitted and cannot be found in taksmanager anymore

41 views Asked by At

I am currently trying to write a short PowerShell script which is supposed to start a custom commandline executable, and wait for the process to finish, and continue execution when the process terminated.

So basically my code looks very simple, like this:

Start-Process "myCmdLineApp.exe" -Wait
Write-Host "Process finished, exitting..."

My observation is that in 99% of all cases, this works flawlessly. But in rare conditions, I observe that myCmdLineApp.exe finished, but the PowerShell script is still waiting for the process. I checked in taskmanager of course, but myCmdLineApp.exe is definitely not running anymore, but my script doesn't continue.

I am now wondering what I might examine further, or what might cause this strange behaviour. Thank you for any ideas or comments on that topic!

0

There are 0 answers