; https://www.autoitscript.com/forum/topic/212366-get-data-from-an-object-without-knowing-its-structure/?do=findComment&comment=1537603
#include <String.au3>
#include <Array.au3>
$aArray = QueryWin32("SELECT ProcessId, CommandLine FROM Win32_Process")
_ArrayDisplay($aArray)
$aArray = QueryWin32("SELECT ProcessId, CommandLine, Caption, ThreadCount, ExecutablePath FROM Win32_Process")
_ArrayDisplay($aArray)
$aArray = QueryWin32('SELECT ProcessId, CommandLine, Caption, ThreadCount, ExecutablePath FROM Win32_Process WHERE Caption = "msedge.exe"')
_ArrayDisplay($aArray)
;--------------------------------------------------------------------------------------------------------------------------------
Func QueryWin32($sQueryString)
Local $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
; $sQuery = "SELECT CommandLine, ProcessId FROM Win32_Process"
Local $oProcesses = $oWMI.ExecQuery($sQueryString, "WQL", 0x30)
Local $aPart = StringSplit(_StringBetween($sQueryString, "SELECT ", " FROM Win32_")[0], ", ", 1)
Local $aResult[1][$aPart[0]]
Local $idx = 0
; make header of the collection
For $i = 1 To $aPart[0]
$aResult[0][$i - 1] = $aPart[$i]
;ConsoleWrite($i & ") " & $aPart[$i] & @CRLF)
Next
; make the value of the collection
For $oProcess In $oProcesses
$idx += 1
ReDim $aResult[$idx + 1][$aPart[0]]
For $i = 1 To $aPart[0]
Local $sExeString = Execute('$oProcess.' & $aPart[$i])
;ConsoleWrite($aPart[$i] & "=" & $sExeString & @CRLF)
$aResult[$idx][$i - 1] = $sExeString
Next
Next
Return $aResult
EndFunc ;==>QueryWin32process
#cs
string CreationClassName;
string Caption;
string CommandLine;
datetime CreationDate;
string CSCreationClassName;
string CSName;
string Description;
string ExecutablePath;
uint16 ExecutionState;
string Handle;
uint32 HandleCount;
datetime InstallDate;
uint64 KernelModeTime;
uint32 MaximumWorkingSetSize;
uint32 MinimumWorkingSetSize;
string Name;
string OSCreationClassName;
string OSName;
uint64 OtherOperationCount;
uint64 OtherTransferCount;
uint32 PageFaults;
uint32 PageFileUsage;
uint32 ParentProcessId;
uint32 PeakPageFileUsage;
uint64 PeakVirtualSize;
uint32 PeakWorkingSetSize;
uint32 Priority;
uint64 PrivatePageCount;
uint32 ProcessId;
uint32 QuotaNonPagedPoolUsage;
uint32 QuotaPagedPoolUsage;
uint32 QuotaPeakNonPagedPoolUsage;
uint32 QuotaPeakPagedPoolUsage;
uint64 ReadOperationCount;
uint64 ReadTransferCount;
uint32 SessionId;
string Status;
datetime TerminationDate;
uint32 ThreadCount;
uint64 UserModeTime;
uint64 VirtualSize;
string WindowsVersion;
uint64 WorkingSetSize;
uint64 WriteOperationCount;
uint64 WriteTransferCount;
#CE