Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Pause Execution

$
0
0

Summary: Use Windows PowerShell to pause execution for a specific time to wait for a process to exit.

Hey, Scripting Guy! Question 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?

Hey, Scripting Guy! Answer 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. 


Viewing all articles
Browse latest Browse all 3333

Trending Articles