P
Poniente
Can anyone help me reproduce the values in the CPU column of the tab
‘processes’ of the Windows task manager in excel?
I’d like to integrate these values in the code below, which lists the
active processes.
Unfortunately, the line ‘objProcess.PercentProcessorTime’ does not
work.
Your help is appreciated!
Poniente
Sub OwnerOfProcesses()
Dim objWMIService As Object
Dim colProcessList As Object
Dim objProcess As Object
Dim strNameOfUser As Variant
Dim strUserDomain As Variant
Dim colProperties As String
Dim MyList() As Variant
Dim x As Long
Set objWMIService = GetObject(strWmgt)
Set colProcessList = objWMIService.ExecQuery(strWmiQ)
x = colProcessList.Count
ReDim MyList(0 To (x - 1), 0 To 4)
On Error Resume Next
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
MyList(x, 4) = objProcess.PercentProcessorTime ‘ Help requested:
this line generates an error
x = x + 1
Next
Range("Log_Processes").Resize(x, 5).Value = MyList
Set objWMIService = Nothing 'JBC
Set colProcessList = Nothing 'JBC
Set objProcess = Nothing 'JBC
End Sub
‘processes’ of the Windows task manager in excel?
I’d like to integrate these values in the code below, which lists the
active processes.
Unfortunately, the line ‘objProcess.PercentProcessorTime’ does not
work.
Your help is appreciated!
Poniente
Sub OwnerOfProcesses()
Dim objWMIService As Object
Dim colProcessList As Object
Dim objProcess As Object
Dim strNameOfUser As Variant
Dim strUserDomain As Variant
Dim colProperties As String
Dim MyList() As Variant
Dim x As Long
Set objWMIService = GetObject(strWmgt)
Set colProcessList = objWMIService.ExecQuery(strWmiQ)
x = colProcessList.Count
ReDim MyList(0 To (x - 1), 0 To 4)
On Error Resume Next
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
MyList(x, 4) = objProcess.PercentProcessorTime ‘ Help requested:
this line generates an error
x = x + 1
Next
Range("Log_Processes").Resize(x, 5).Value = MyList
Set objWMIService = Nothing 'JBC
Set colProcessList = Nothing 'JBC
Set objProcess = Nothing 'JBC
End Sub