VB icon

WMI Sample to list running Processes

Email
Submitted on: 4/9/2018 5:41:09 PM
By: A_X_O 
Level: Beginner
User Rating: Unrated
Compatibility: VbScript (browser/client side)
Views: 1287
 
     Using the WMI Objects to create a list of running process ID's / Handles, alongside the process name

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: WMI Sample to list running Processes
' Description:Using the WMI Objects to create a list of running process ID's / Handles, alongside the process name
' By: A_X_O
'**************************************

'
'------------------------------------------------------------------------------	'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'		Demonstration: Windows 10, WMI List Process ID & Name		'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'										'
'	Purpose		:	Demonstrates WMI List Processes			'
'	-----------------------------------------------------------------------	'
'	Creation Date	: 	09/04/2018 [dd/mm/yyyy]				'
'	Version		:	1.0						'
'	Designer	:	Fabian						'
'										'
'##############################################################################	'
'			MODIFICATION HISTORY					'
'------------------------------------------------------------------------------	'
'	Version		:	1:0	09/04/2018	Create the Sample	'
'										'
'------------------------------------------------------------------------------	'		
'
Public Const strComputer = "." 
Public Const ListFile = "ProcList.txt"
Public Const PHand = "Process Handle:"
Public Const PName = "Process Name:"
'
Dim objWMIService
Dim colItems
Dim FSO
Dim ProcList
Dim Pos
Dim Loc
'
Set FSO = CreateObject("Scripting.FileSystemObject")
'
	Pos = InStrRev((Wscript.ScriptFullName),"\",-1,1) 
'
	Loc = Mid((Wscript.ScriptFullName),1, Pos)
'
	Loc = (Loc & ListFile)
'
Set ProcList = FSO.CreateTextFile((Loc), True)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process",,48) 
'
For Each objItem in colItems 
'
	ProcList.Write PHand & Space(1) & objItem.Handle & _
			VBTab & PName & Space(1) & _
			objItem.Name & VbCrLf 
'
Next
'
	ProcList.Close
'
'
'


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.