Sign in to follow this  
Followers 0
Zohar

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

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted

.. 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

 


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

Share this post


Link to post
Share on other sites

#3 ·  Posted

Cool!

Thank you very much Chimp :)

Share this post


Link to post
Share on other sites

#4 ·  Posted

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

 


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted

BTW,
Is it possible to know if the HDD is busy, not related to any specific process?

Share this post


Link to post
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
Sign in to follow this  
Followers 0