2

在 Process Explorer 术语中,它是WS Private Bytes,而在任务管理器术语中,它是Private Working Set

我想要一个命令行实用程序来显示给定进程名称的此信息。

编辑

一个 powershell 脚本也可以。

4

1 回答 1

7

PowerShell您可以使用:

[编辑]

function ProcessInfo
{
    param
    ([String]$processName)

    $workingSet = get-counter -counter "\Process($processName)\Working Set - Private" | select -expandproperty countersamples | select cookedvalue
    $privateBytes = get-counter -counter "\Process($processName)\Private Bytes" | select -expandproperty countersamples | select cookedvalue

    get-process $processName | select `
        name, `
        @{Name="Private Working Set"; Expression = {$workingSet.CookedValue}},`
        @{Name="WS Private Bytes"; Expression = {$privateBytes.CookedValue}}
}

ProcessInfo("winrar")

[编辑2]

这是一个改进版本,它以进程 ID 作为参数。

function GetProcessInfoById
{
    param
    ([int]$processId)

    Get-WmiObject -class Win32_PerfFormattedData_PerfProc_Process | where{$_.idprocess -eq $processId} | select `
    @{Name="Process Id"; Expression = {$_.idprocess}},`
    @{Name="Counter Name"; Expression = {$_.name}},`
    @{Name="Private Working Set"; Expression = {$_.workingSetPrivate / 1kb}}        
}

GetProcessInfoById 380

这是一个将进程名称作为参数的版本。这可能会返回多个值(每个流程实例一个),您可以通过Process Id.

function GetProcessInfoByName
{
    param
    ([string]$processName)

    Get-WmiObject -class Win32_PerfFormattedData_PerfProc_Process | where{$_.name -like $processName+"*"} | select `
    @{Name="Process Id"; Expression = {$_.idprocess}},`
    @{Name="Counter Name"; Expression = {$_.name}},`
    @{Name="Private Working Set"; Expression = {$_.workingSetPrivate / 1kb}}
}

GetProcessInfoByName svchost
于 2012-12-14T12:58:37.760 回答