Jump to content

Recommended Posts

Posted

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

Posted

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...