get names of all Applications currently running

  • Thread starter Thread starter gs2000
  • Start date Start date
G

gs2000

Is it possible to get the names of the application that are currentl
running by VB, or VBA?

More specifically, I would like to be able to get the information tha
is listed in the "Applications" tab of the Task Manager.
 
perhaps something like this may help.

WinXp / Xl2003

Option Explicit
'// WMI String Constants
Private Const strWmgt As String = "winmgmts:" &
"{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2"
Private Const strWmiQ As String = "Select * from Win32_Process"

Dim hWnd As Long
Dim MyList()
'// helper Subs
Sub OwnerOfProcesses()
Dim objWMIService As Object
Dim colProcessList As Object
Dim objProcess As Object
Dim strNameOfUser
Dim strUserDomain
Dim colProperties As String
Dim x As Double
'//

Set objWMIService = GetObject(strWmgt)
Set colProcessList = objWMIService.ExecQuery(strWmiQ)

x = colProcessList.Count
ReDim MyList(x - 1, 3)
x = 0
For Each objProcess In colProcessList
colProperties = objProcess.GetOwner(strNameOfUser, strUserDomain)
MyList(x, 0) = objProcess.Name
MyList(x, 1) = strUserDomain
MyList(x, 2) = strNameOfUser
MyList(x, 3) = objProcess.Handle
x = x + 1
Next

With Sheet1
.Range(.Range("A1:D2"), .Range("A1:D2").End(xlDown)).ClearContents
.[A1].Resize(x, 4) = MyList
.UsedRange.EntireColumn.AutoFit
End With
MsgBox "Processes: " & x
End Sub
 
I guess the above wouldn't work with Excel 2000, would it? Where woul
be a good place/web resource to learn what you did with WMI? I wa
lost there.

Thank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top