Friday, June 4, 2010

Wscript- Retrieve Process Memory Usage

'Retrieve all memory usage of a particular process currently active n a system using Windows Script
'Source : MSDN
'02/06/2006

**************************************************************************

Sub retrieveMemoryUsage(Exe_Name)

'On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '"&Exe_Name&"'")
For Each objProcess in colProcessList
'objProcess.Terminate()
'msgbox objProcess.ProcessId
var = objProcess.WorkingSetSize
msgbox int(var/1024) &" K"
Next

End Sub

retrieveMemoryUsage("Rtvscan.exe")

**************************************************************************

No comments: