3

我想杀死所有运行超过 5 分钟的 Internet Explorer 进程。这必须是使用 Powershell v1.0 的一行命令。

4

4 回答 4

4

其他方式:

 get-process iexplore | ? { ([DateTime]::Now - $_.StartTime).TotalSeconds -gt 300 } | stop-process
于 2012-07-10T09:50:17.260 回答
1
Get-Process iexplore -ErrorAction SilentlyContinue |
Where-Object { $_.StartTime -and (Get-Date).AddMinutes(-5) -gt $_.StartTime } |
Stop-Process
于 2012-07-10T10:26:41.580 回答
0

至少在 powershell v2 以下命令应该停止所有早于 5 分钟的 IE 进程:

Get-Process | 
    select -Property ProcessName, StartTime |
    ? { (($_.StartTime -ne $null) -and
         (([DateTime]::Now - $_.StartTime).TotalMinutes -ge 5) -and
         ($_.ProcessName -eq "iexplore")) } |
    Stop-Process
于 2012-07-10T09:40:33.147 回答
-1

如果您只想删除第一个进程,CPU 使用率很高:

get-process iexplore | sort –descending cpu | select –First 1 | stop-process
于 2015-07-31T21:55:29.150 回答