Jump to content

[Solved] How to Programmatically Get the "I/O Reads" of a Process?


Recommended Posts

Hi


If you open Task Manager and switch to the Processes tab,
you can then select which columns to display (Menu: View\SelectColumns...)

One possible column there, is "I/O Reads".

How can I get the I/O Reads of a process, programmatically?
 

If there are several ways, please tell them so i will try them and choose one..


Thank you

Edited by Zohar
Link to comment
Share on other sites

.. one of possible ways using wmic:

#include <AutoItConstants.au3>
#include <StringConstants.au3>

Local $sProcess = "explorer.exe" ; <-- your target process
Local $sOutput = ""

; build your wmic query
Local $sWMICquery = 'wmic process where name="' & $sProcess & '" get readoperationcount /value'

; run your query hidden and with redirected I/O streams
Local $hPid = Run($sWMICquery, '', @SW_HIDE, $STDERR_MERGED)

Do ; get command output
    Sleep(100)
    $sOutput &= StdoutRead($hPid) ; get wmic output from redirected streams
Until @error ; error occurs when command has finished

$sOutput = StringStripWS($sOutput, $STR_STRIPALL) ; remove all @cr and spaces from output

MsgBox(0, 'Debug', "Process: " & $sProcess & @CRLF & $sOutput) ; show result

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

You are welcome :)

Here another way using WMI instead:

Local $Computername = "localhost"
_WMI_ProcessGetInfos($Computername)

Func _WMI_ProcessGetInfos($Computername)
    If Ping($Computername) Then

        Local $vObjWMI = ObjGet("winmgmts:\\" & $Computername & "\root\cimv2")
        If IsObj($vObjWMI) Then
            ConsoleWrite("Debug: OK WMI is obj" & @CRLF)
        Else
            Return SetError(1, 0, "") ; problems
        EndIf

        ; https://msdn.microsoft.com/en-us/library/aa394372(v=vs.85).aspx
        Local $vObjItems = $vObjWMI.ExecQuery('SELECT * FROM win32_process') ; get all properties of all process

        If IsObj($vObjItems) Then
            ConsoleWrite("Debug: Total processes found: " & $vObjItems.count & @CRLF)
            For $vObjItem In $vObjItems
                ConsoleWrite($vObjItem.Name & " WriteOperationCount: " & $vObjItem.WriteOperationCount & @CRLF)
                ; all retrievables properties (case sensitive!) are listed in the "properties" section of following link
                ; https://msdn.microsoft.com/en-us/library/aa394372(v=vs.85).aspx
            Next
            Return SetError(0)
        EndIf
    Else
        ; remote computer not responding
        Return SetError(1, 0, "") ; problems
    EndIf

EndFunc   ;==>_WMI_ProcessGetInfos

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Thank you

If I remember correctly,
in the past, the WMI object was slow..

The DOS Command (WMIC) does not seem to have any delay, it works perfect..
So I stay with it..

Edited by Zohar
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...