2017-04-10 10 views

答えて

0

は、以下の内容でrun.ps1というファイルを作成します。

$apps = New-Object System.Collections.Generic.List[Object] 

$app = Start-Process "notepad.exe" -passthru 
$apps.Add($app) 

$app = Start-Process "notepad.exe" -passthru 
$apps.Add($app) 

Write-Host "Press any key to terminate ..." 
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") 

#Kill the running processes 
foreach ($app in $apps) 
{ 
    Write-Host "Killing" ($app.Id -as [string]) 
    Stop-Process $app.Id 
} 

をそして今、あなたは使用してそれを実行することができます。

powershell.exe -executionpolicy remotesigned -File ./test.ps1 
関連する問題