Sub PrintPerf(item)
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("powershell Get-Process | Sort-Object " & item & " -desc | Select-Object -first 1 | Format-Table " & item & ",ProcessName -hidetableheader")
Do
line = Trim(objExec.StdOut.ReadLine())
If Len(line) > 0 Then
value = Left (line, InStr (line, " ")-1)
process = Mid (line, InStr (line, " ")+1, Len (line) )
WScript.StdOut.WriteLine ""
WScript.StdOut.WriteLine "process name: " & process & " "
End If
Loop While Not objExec.Stdout.atEndOfStream
End Sub
' Generate module: CPU ussage
WScript.StdOut.WriteLine ""
WScript.StdOut.WriteLine ""
WScript.StdOut.WriteLine ""
PrintPerf "CPU"
WScript.StdOut.WriteLine ""
' Generate module: MEM ussage
WScript.StdOut.WriteLine ""
WScript.StdOut.WriteLine ""
WScript.StdOut.WriteLine ""
PrintPerf "WS"
WScript.StdOut.WriteLine ""