Prev: How to using SMTP mail by VBS
Next: Enumerate all printers installed at computer startup (With Startup GPO)
From: moonhkt on 28 May 2010 04:06 HI All I have below vbs, to report win32 process, But I does not know how to select a process using A lot of CPU resource , said over 70% ? Ouptut as below c:\temp> c:\temp>chkprocess.vbs ID Caption Pool Usage ====== ============================== ========== 0 System Idle Process 0 4 SYSTEM 0 676 smss.exe 13400 732 csrss.exe 161548 764 winlogon.exe 75620 808 services.exe 91280 820 lsass.exe 63596 1020 ati2evxx.exe 26984 1036 svchost.exe 47296 1108 svchost.exe 52320 1220 svchost.exe 448212 Option Explicit Dim pad(4) dim strComputer dim objWMIService dim ele dim colProcess function fmt (str,lenstr) if lenstr - len(str) > 0 then fmt = str + string(lenstr - len(str), " " ) else fmt = str end if end function strComputer = "." pad(1)= 6 pad(2) = 30 pad(3) = 10 Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery("SELECT * FROM Win32_Process ") Wscript.Echo fmt("ID",pad(1)), fmt("Caption",pad(2)), fmt("Pool Usage",pad(3)) Wscript.Echo string(pad(1), "=") , string(pad(2),"="),string(pad(3),"=") For Each ele in colProcess if ele.caption <> "r2win.exe" then Wscript.Echo fmt(cstr(ele.ProcessId),pad(1)), _ fmt(ele.Caption,pad(2)), _ fmt(cstr(ele.QuotaPeakPagedPoolUsage),pad(3)) end if Next set ObjWMIService = nothing set colProcess = nothing |