'==========================================================================
'
' NAME: <ListRunningProcesses.vbs>
'
' AUTHOR: Ed Wilson , MS
' DATE  : 4/29/2006
'
' COMMENT: <Lists information on running processes on system>
'
'==========================================================================
Option Explicit 
'On Error Resume Next
dim strComputer		'computer to connect to with wmi
dim wmiNS					'wmi namespace
dim wmiQuery			'the wmi query
dim objWMIService	'connection using wmi moniker
dim colItems			'collection of wmi objects
Dim objItem				'individual item in the collection
Dim strProperties 'properties to choose
Dim strValues			'string of wmi values

strComputer = "."
wmiNS = "\root\cimv2"
strProperties = "name,processID,pageFaults,WorkingSetSize"
wmiQuery = "Select " & strProperties & " from win32_process" &_
	" where processID <>0"
	
Set objWMIService = GetObject("winmgmts:\\" & strComputer & wmiNS)
Set colItems = objWMIService.ExecQuery(wmiQuery)

For Each objItem in colItems
	With objItem
	  strValues = .name & "," & .processID & "," &_
	   .PageFaults & "," & .WorkingSetSize
	End With
	WScript.Echo strValues
Next

