Jump to content

Function ProcessGetStats Failure


 Share

Recommended Posts

@Chaym
You could use WMI object or _WinAPI_GetProcessMemoryInfo().
Here it is an example:

#include <Array.au3>
#include <AutoItConstants.au3>
#include <WinAPI.au3>

Global $arrProcessList, _
       $arrProcessStats, _
       $arrProcessMemoryInfo, _
       $objWMI, _
       $objWMIQueryResult


$objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
$arrProcessList = ProcessList("")

For $i = 1 To $arrProcessList[0][0] Step 1
    $objWMIQueryResult = $objWMI.ExecQuery("SELECT WorkingSetSize, PeakWorkingSetSize FROM Win32_Process WHERE ProcessId = " & $arrProcessList[$i][1])

    $arrProcessStats = ProcessGetStats($arrProcessList[$i][1], $PROCESS_STATS_MEMORY)
    $arrProcessMemoryInfo = _WinAPI_GetProcessMemoryInfo($arrProcessList[$i][1])

    For $objWMIResult In $objWMIQueryResult

        ConsoleWrite("ProcessName                    : " & $arrProcessList[$i][0] & @CRLF & _
                     "ProcessId                      : " & $arrProcessList[$i][1] & @CRLF & _
                     "WorkingSetSize" & @CRLF & _
                     " o WMI                         : " & $objWMIResult.WorkingSetSize & @CRLF & _
                     " o ProcessGetStats()           : " & $arrProcessStats[0] & @CRLF & _
                     " o _WinAPI_GetProcessMemoryInfo: " & $arrProcessMemoryInfo[2] & @CRLF& _
                     "PeakWorkingSetSize" & @CRLF & _
                     " o WMI                         : " & $objWMIResult.PeakWorkingSetSize * 1024 & @CRLF & _
                     " o ProcessGetStats()           : " & $arrProcessStats[1] & @CRLF & _
                     " o _WinAPI_GetProcessMemoryInfo: " & $arrProcessMemoryInfo[1] & @CRLF & @CRLF)
    Next
Next

$objWMI = 0

:)
 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Developers

I am wondering why we think it will work with another tool while it really looks like a authorization issue ..... or am I missing something? :) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I think you are right Jos.

I mapped all the processes that are not passing ProcessGetStats(ProcessName)  to see

what authorization is missing.

I'm looking at Process properties in task manger, in TAB 'Security' to see if can find the problem

It seems that all the processes that are not passing ProcessGetStats are also services....

Edited by Chaym
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...