'************************************** ' Name: WMI Sample to list running Proce ' sses ' Description:Using the WMI Objects to c ' reate a list of running process ID's / H ' andles, alongside the process name ' By: A_X_O ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** ' '--------------------------------------- ' --------------------------------------- ' '+++++++++++++++++++++++++++++++++++++++ ' ++++++++++++++++++++++++++++++++ ' ' Demonstration: Windows 10, WMI List P ' rocess ID & Name ' '+++++++++++++++++++++++++++++++++++++++ ' ++++++++++++++++++++++++++++++++ ' ' ' ' Purpose : Demonstrates WMI List Proce ' sses ' ' -------------------------------------- ' --------------------------------- ' ' Creation Date : 09/04/2018 [dd/mm/yyy ' y] ' ' Version : 1.0 ' ' Designer : Fabian ' ' ' '####################################### ' ####################################### ' ' MODIFICATION HISTORY ' '--------------------------------------- ' --------------------------------------- ' ' Version : 1:0 09/04/2018 Create the S ' ample ' ' ' '--------------------------------------- ' --------------------------------------- ' ' 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 ' ' '