Jump to content
Sign in to follow this  
ripdad

_WMI_InstancesOf_v2.25

Recommended Posts

This function (version 1), was developed solely for applications I needed it for.
It was only tested with Class names that was needed in those scripts.

And so, I didn't want to release it by itself because I knew it needed some more
work before I did that.

Recently, I delved back into it after several years and am now releasing version 2,
which was mostly rewritten over the past several weeks.

What does it do? It retrieves the properties and values pertaining to your computer,
operating system and devices. All you need is a valid Win32 Class Name.

So, here it is -- let me know if you have any issues!

Updated to v2.25, January 14, 2017

Download: _WMI_InstancesOf_v2.25.au3

 

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

I tested the class string:
Win32_NTLogEvent WHERE Logfile="System"
and it returns an error because file is in Logfile. Oh well.


Edit: fixed in v2.11



 



 

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

Updated to v2.11
- Fixed a problem with WHERE statement strings
- Now supports horizontal arrays

Examples:

#include 'array.au3'
#include '_WMI_InstancesOf_v2.11.au3'

; Example 1 - vertical array

Local $rtn = _WMI_InstancesOf('Win32_OperatingSystem', 1)
Local $nError = @error
If IsArray($rtn) Then
    _ArrayDisplay($rtn)
Else
    MsgBox(0, '', 'Error: ' & $nError & @CRLF & $rtn)
EndIf
Exit
#include 'array.au3'
#include '_WMI_InstancesOf_v2.11.au3'

; Example 2 - horizontal array

Local $sClass = 'Win32_NTLogEvent WHERE Logfile="System"'
$sClass &= ' And EventCode="6005"'
$sClass &= ' And TimeGenerated>"20160101000000.000000-000"'; date range start (get month, December 2016)
$sClass &= ' And TimeGenerated<"20170101000000.000000-000"'; date range end + 1
Local $NoBlanks = 0; include blank values
Local $nHorizontal = 1; return horizontal array ($NoBlanks = 0, must be used)
Local $nStatement = 1; get these properties only
Local $strProperty = 'ComputerName|EventCode|EventIdentifier|TimeGenerated'
Local $rtn = _WMI_InstancesOf($sClass, $NoBlanks, $nHorizontal, $nStatement, $strProperty)
Local $nError = @error
If IsArray($rtn) Then
    _ArraySort($rtn, 0, 1, 0, 3); <- sort by date column (user dependent)
    _ArrayDisplay($rtn)
Else
    MsgBox(0, '', 'Error: ' & $nError & @CRLF & $rtn)
EndIf
Exit
#include 'array.au3'
#include '_WMI_InstancesOf_v2.11.au3'

; Example 3 - horizontal array

Local $strProperty = 'Name|NetConnectionID|Manufacturer|NetConnectionStatus'
Local $rtn = _WMI_InstancesOf('Win32_NetworkAdapter', 0, 1, 1, $strProperty)
Local $nError = @error
If IsArray($rtn) Then
    _ArrayDisplay($rtn)
Else
    MsgBox(0, '', 'Error: ' & $nError & @CRLF & $rtn)
EndIf
Exit

 

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

Updated to v2.25 - see first post

This should be it, unless someone has a suggestion or problem with the script.

 

 

 


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By shital
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** RunAs(test", @ComputerName, "testinng",2,"wmic product where ""name= '%notepadexamples%'"" call uninstall", @SystemDir & "\wbem", @SW_MAXIMIZE)  it not working 
       
    • By Colduction
      Hi AutoIt Programmers!

      I've seen a code that gives Name of Group by writing it's group's SID, but this one response very slower than Windows Command-Line WMIC
       
      Func _GetLocalGroupName($sSID = 'S-1-5-18') $objWMIService = ObjGet ("winmgmts:\\" & @ComputerName & "\root\cimv2") $colItems = $objWMIService.ExecQuery('SELECT Name FROM Win32_Group where SID="' & $sSID & '"') For $GroupNames in $colItems MsgBox (0,"",$GroupNames.Name) ExitLoop Next EndFunc I don't want call and use any third-party programs even CMD, i just want use from Windows API, netapi32.dll or AutoIt Functions (Standalone).
      Do you have any idea to improve speed/performance of this code? I'll happy of your comments
       
       
       
      ====================== SOLOUTION by @Subz ======================
       
    • By jresine
      Hello, is it possible to know via a script or command, to have the percentage of disk usage of a process? thank you in advance.
      ps: see image

    • By Dwalfware
      HI
      Another head scratched
      Anyone solve how to get the IPV6 from WMI?
      I followed the usual SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='" & GUICtrlRead($cboAdapters) & "'
      get the index 
      port it to 
      Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
      All i can see is IPv4 addresses
      My question is is there another place the IPv6 information is hiding? I configured my LAN with IPV6 and my wireless with IPv4 so I can see what shows.
      Thanks in Advance.
      PS. I did try google
       
    • By Dwalfware
      Hi Folks
      Can not get my head around this one.
      This function gets the DNS object s
      If you have two DNS entries fine. but if you have only one! Trouble
      $objItem.DNSServerSearchOrder[0] = Primary DNS
      $objItem.DNSServerSearchOrder[1] = Secondry DNS not always there. I need a way to return 0 if not there or the IP if its there.
      Or is there a way to tell how many objects there are in the "[?]"
      I'm terrible at WMI errors, thanks for help in advance.
      Func _GETcurrentNICinfo2() $oErrors = ObjEvent("AutoIt.Error", "Error_Handle") Local $DnsSecondry Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" ) Local $query = $objWMIService.ExecQuery("SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 ) If @error Then Return 0 If NOT IsObj($query) Then Return 0 Else For $objItem In $query Return $objItem.DNSServerSearchOrder[1] next Endif EndFunc  
×
×
  • Create New...