Sign in to follow this  
Followers 0
DDM

WMI hardware information

5 posts in this topic

Hi

Can anyone with getting wmi information ?

ive tried the following code without success, can't see wants wrong !!

Func getsensorinfo()

local $strComputer = "localhost"

Local $objWMIService

Local $colItems,$objItem

local $strdisplay

$colItems = ""

$strdisplay = ""

;$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\hardware")

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\hardware")

If IsObj($objWMIService) Then

$colItems = $objWMIService.ExecQuery("Select * from NumericSensor")

If IsObj($colItems) Then

For $objItem In $colItems

$strdisplay &= "Sensor" & @CRLF

$strdisplay &= @CRLF

$strdisplay &= "Caption : " & $objItem.Caption

$strdisplay &= @CRLF

$strdisplay &= "Name : " & $objItem.CreationClassName

$strdisplay &= @CRLF

$strdisplay &= "Version : " & $objItem.Description

$strdisplay &= @CRLF

Next

EndIf

EndIf

MsgBox(4096,"WMI Sensor Object", $strdisplay)

EndFunc

Share this post


Link to post
Share on other sites



I don't have the namespace root\hardware to test your script but it looks good.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Please have a look at the This generates all kind of WMI code for AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I don't have the namespace root\hardware to test your script but it looks good.

Br,

UEZ

Nope you have it.

You can't connect to that namespace directly. You can access it from CIM_NumericSensor, which DOES exist however an Administrator account can't see it or its values. WMI Tools does not list it if you have the default "Show classes which can have instances" however it does appear if you select "Show all classes" option.

Global $sWMIService, $objWMIService, $colItems, $objItem, $oItem
Global $xCaption, $xName, $xVersion

$sWMIService = "winmgmts:\\" & @ComputerName & "\root\CIMV2"
$objWMIService = ObjGet($sWMIService)
IF IsObj($objWMIService) Then
$colItems = $objWMIService.ExecQuery("SELECT * FROM CIM_NumericSensor")
    If IsObj($colItems) Then
        For $oItem In $colItems
            $xCaption = $oItem.Caption
            $xName = $oItem.Name
            ;$xVersion = $oItem.Version
        Next
    EndIf
MsgBox (4096, "test", "Sensor" & @CRLF & "Caption : " & $xCaption & @CRLF & "Name : " & $xName)
EndIF

The MsgBox comes up, but the values are blank. WMI Tools reports to me that CIM_NumericSensor: "The selected classes do not have instances."

CIM_NumericSensor Class on MSDN

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

With WBEMTEST you can also list WMI namespaces and instances on your system. According to the link you provided it requires the namespace root\hardware with can be found in Ipmiprv.mof which is not installed on my system.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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