VBA Getting program names and task ID of running processes -
VBA Getting program names and task ID of running processes -
how programme names , task ids of running processes. shell()
returns task id of initiated process. similar, task id , name of processes running , not created macro. i've found code returns programs names output lacks task ids info :
http://www.vbaexpress.com/forum/archive/index.php/t-36677.html
sub test_allrunningapps() dim apps() variant apps() = allrunningapps range("a1").resize(ubound(apps), 1).value2 = worksheetfunction.transpose(apps) range("a:a").columns.autofit end sub 'similar to: http://msdn.microsoft.com/en-us/library/aa393618%28vs.85%29.aspx public function allrunningapps() variant dim strcomputer string dim objservices object, objprocessset object, process object dim odic object, a() variant set odic = createobject("scripting.dictionary") strcomputer = "." set objservices = getobject("winmgmts:\\" _ & strcomputer & "\root\cimv2") set objprocessset = objservices.execquery _ ("select name win32_process", , 48) each process in objprocessset if not odic.exists(process.name) odic.add process.name, process.name next a() = odic.keys set objprocessset = nil set odic = nil allrunningapps = a() end function
you can alter sql read select name, processid win32_process
then in loop, name utilize process.properties_("name").value
, process.properties_("processid").value
needed.
vba
Comments
Post a Comment