PowerShell Logo Small

Wait-Process



This is the built-in help made by Microsoft for the command 'Wait-Process', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Waits for the processes to be stopped before accepting more input.

SYNTAX


Wait-Process [-Id] <Int32[]> [[-Timeout] <int>] [<CommonParameters>]
Wait-Process -InputObject <Process[]> [[-Timeout] <int>] [<CommonParameters>]
Wait-Process [-Name] <string[]> [[-Timeout] <int>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Wait-Process cmdlet waits for one or more running processes to be stopped before accepting input. In the Windows PowerShell console, this cm
dlet suppresses the command prompt until the processes are stopped. You can specify a process by process name or process ID (PID), or pipe a proc
ess object to Wait-Process.

Wait-Process works only on processes running on the local computer.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=135277
Get-Process
Start-Process
Stop-Process
Wait-Process
Debug-Process

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>$nid = (get-process notepad).id

C:\PS> stop-process -id $nid

C:\PS> wait-process -id $nid



Description
-----------
These commands stop the Notepad process and then wait for the process to be stopped before proceeding with the next command.

The first command uses the Get-Process cmdlet to get the ID of the Notepad process. It saves it in the $nid variable.

The second command uses the Stop-Process cmdlet to stop the process with the ID saved in $nid.

The third command uses the Wait-Process cmdlet to wait until the Notepad process is stopped. It uses the ID parameter of Wait-Process to identify
the process.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>$p = get-process notepad

C:\PS> wait-process -id $p.id

C:\PS> wait-process -name notepad

C:\PS> wait-process -inputobject $p



Description
-----------
These commands show three different methods of specifying a process to the Wait-Process cmdlet. The first command gets the Notepad process and sa
ves it in the $p variable.

The second command uses the ID parameter, the third command uses the Name parameter, and the fourth command uses the InputObject parameter.

These commands have the same results and can be used interchangeably.








-------------------------- EXAMPLE 3 --------------------------

C:\PS>wait-process -name outlook, winword -timeout 30



Description
-----------
This command waits 30 seconds for the Outlook and Winword processes to stop. If both processes are not stopped, the cmdlet displays a non-termina
ting error and the command prompt.