Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

CPU Temperature

  • 20-02-2008 12:17pm
    #1
    Registered Users, Registered Users 2 Posts: 86 ✭✭


    Hi,
    has anyone any idea of how to get cpu temperature ,motherboard temp etc using either vb6 or vb.net.
    I am getting some statistics from "MSAcpi_ThermalZoneTemperature" but the figures dont make much sence to me.

    Any one encounter this before?


Comments

  • Registered Users, Registered Users 2 Posts: 995 ✭✭✭cousin_borat


    System and appliance monitoring tools like HP OpenView an Dells OpenManage install MIB files for 3rd party devices that they are to manage.

    Perhaps there is a way to get VB to do something with the MIB file for your particular machine...

    You could try getting a MIB viewer tool and reverse engineering or searching for MIB and VB on google


  • Closed Accounts Posts: 317 ✭✭tiptap


    This works, from forums on Microsoft.
    PublicClass Form1
    PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
    Dim searcher AsNew ManagementObjectSearcher( _
    "root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature")

    ForEach queryObj As ManagementObject In searcher.Get()
    Dim temp AsDouble = CDbl(queryObj("CurrentTemperature"))
    temp = (temp - 2732) / 10.0
    MessageBox.Show(temp.ToString)
    Next
    Catch err As ManagementException
    MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
    EndTry
    EndSub
    EndClass


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    Thanks tiptap,

    when i apply the line : temp = (temp - 2732) / 10.0 to my figures they seem to make more sence. Thanks for that.


  • Closed Accounts Posts: 317 ✭✭tiptap


    RedRag wrote: »
    Thanks tiptap,

    when i apply the line : temp = (temp - 2732) / 10.0 to my figures they seem to make more sence. Thanks for that.

    yeah, the converstion makes more sense all right,
    good stuff.


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    Having more trouble with this. It works perfectly on developer machine and on one test pc but fails with the following error on another test pc.

    For loop not initialised

    Below is the code:

    Dim strServer As String
    Dim strVitals As String
    Dim objWMI As Object
    Dim objInstances As Object
    Dim objInstance As Object
    On Error GoTo Error_Handler
    strVitals = ""
    strServer = "."
    Set objWMI = GetObject("winmgmts://" & strServer & "/root\WMI")
    '' W32_TemperatureProbe
    Set objInstances = objWMI.InstancesOf("MSAcpi_ThermalZoneTemperature", 48)
    '' MSAcpi_ThermalZoneTemperature
    m_strXmlPath = strUpLoad & "Vitals.xml"
    Call Create_Virt_Vitals
    On Error Resume Next


    'Think its failing here

    For Each objInstance In objInstances

    With objInstance

    virtVITALS.AddNew

    virtVITALS("Active") = .Active
    virtVITALS("ActiveTripPoint") = Join(.ActiveTripPoint, ", ")
    virtVITALS("ActiveTripPointCount") = .ActiveTripPointCount
    virtVITALS("CriticalTripPoint") = .CriticalTripPoint
    virtVITALS("CurrentTemperature") = (.CurrentTemperature - 2732) / 10
    virtVITALS("InstanceName") = .InstanceName
    virtVITALS("PassiveTripPoint") = .PassiveTripPoint
    virtVITALS("Reserved") = .Reserved
    virtVITALS("SamplingPeriod") = .SamplingPeriod
    virtVITALS("ThermalConstant1") = .ThermalConstant1
    virtVITALS("ThermalConstant2") = .ThermalConstant2
    virtVITALS("ThermalStamp") = .ThermalStamp

    virtVITALS.Update
    End With

    On Error GoTo 0
    Next


    Please help its very frustrating. Any idea why this would happen? :confused:


  • Advertisement
  • Closed Accounts Posts: 317 ✭✭tiptap


    Nothing wrong with the code here,

    Are you logging in with an admin account on the pc that it's not working on, I had something similar before where it was permissions related.


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    The error is actually occuring at the Next in the loop. Yes i'm logging on with an administrator account. I'll try on another user account and see what happens.
    Thanks for your help tiptap.


  • Closed Accounts Posts: 317 ✭✭tiptap


    RedRag wrote: »
    The error is actually occuring at the Next in the loop. Yes i'm logging on with an administrator account. I'll try on another user account and see what happens.
    Thanks for your help tiptap.



    same code though on both machines yes ? working on one and not the other ?
    we should eliminate the code then itself, unless it's some type of dll that's not registered for example, but I doubt it,
    the snippet of code you posted seems to be fine!
    let us know what happens anyway


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    Yea same code on both machines. No luck with different user account I'm all out of patience with this one. I'll come back to it later when I calm down.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    If you are doing this is VB.NET can you get rid of the GOTO 0 handler, and use a try catch block instead!!!!!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    And on the chance that is VB6

    Do you have On Error Resume Next in your code..

    I am wondering if it bouces out earlier and then just mishandles when it gets to the Next statement. Have you tried stepping through the code on the test machine and examining what is happening.

    What is different from this test box as compared to the existing one? Have you looked at another WMI application that checks the same stufff on the test box?


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    Youre Right ginger I removed the:

    On Error Resume Next

    The error is occuring here as i first thought.

    For Each objInstance In objInstances

    The app is being developed in VB6. The test box is a touch screen kiosk not a standard tower. Its running XP pro sp2.


  • Closed Accounts Posts: 317 ✭✭tiptap


    RedRag wrote: »
    Youre Right ginger I removed the:

    On Error Resume Next

    The error is occuring here as i first thought.

    For Each objInstance In objInstances

    The app is being developed in VB6. The test box is a touch screen kiosk not a standard tower. Its running XP pro sp2.


    Out of curiousity, have you tried do while ?


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    I haven't tried do while, don't know how I would structure it to do what I want.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Just an FYI always disable on Error resume next in testing and possibly never use it all, unless you are very sure in your error handling and have it reporting correctly.

    So the object wasnt instiated.. check to see if the WMI service is actually running on the machine


  • Registered Users, Registered Users 2 Posts: 86 ✭✭RedRag


    WMI Service is running everything looks the same on all systems.


Advertisement