Summary: Use Windows PowerShell to pause execution for a specific time to wait for a process to exit.
I have a process that normally exits within four seconds, and I want to pause the execution of my script to wait
for this process to exit. If it does not exit in time, I want an error to occur. How can I easily do this?
Use the Wait-Process cmdlet and specify the name of the process and the wait time:
Wait-Process -Timeout 4 -Name notepad
In this command, if Notepad does not exit within four seconds, and error occurs.