■ 윈도우즈 메모장 3개를 실행시키고 1초 후 모두 종료시키는 방법을 보여준다.
▶ 실행 명령
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$PIDList = New-Object System.Collections.Generic.List[string] for($I = 0; $I -lt 3; $I++) { $Process = Start-Process -FilePath notepad -PassThru $PIDList.Add($Process.Id) } Start-Sleep -Seconds 1 for($I = 0; $I -lt 3; $I++) { Stop-Process -Id $PIDList[$I] -ErrorAction SilentlyContinue } $PIDList.Clear() |