Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I read the processor's temperature in VB?

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
A customer of mine has some remote unattended computers connected to a monitoring point on a LAN. They are on a railway station showing departures.
These computers are in a box with an external fan and air filter.

Is there any way I can monitor the cpu temperature so that if people forget to clean the air filter or the box fan fails, the average temperature rises beyond a set limit and sends a warning up the LAN.
There are some stand alone routines that show the temp but I want to send the temp out the LAN port with my existing vb6 application.

Thanks Ted
 
Download ScriptoMatic2. It shows how to write a VBS script to get the cpu temp, among other things.
Have your app send a message if the temp gets too hot.

I did something like that before. We used 15 minutes for each computer as a poll time.

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Thanks, I downloaded it but I obviously need much more info on where to start.
Although I know a fair bit about vb6, I realised dont understand what vbscript really is!
Where does the 'script' you end up writing go, and how do I find out what reference to use?
Do I put extra code somewhere in my VB app or in some other form of external batch file or something like that?
Or do I add some sort of project reference like you do with file scripting reference to get and change attributes of a file?
It is not obvious in what I downloaded.
Thanks
 
There is a "Win32_TemperatureProbe" class which is supposed to return this information. However, I is not working for me although I can see the CPU temperature in BIOS setup. I tried it on three different machines.

The VBScript code sample on MSDN is also not working.
 
yes Hypetia, I tried that one. It is apparently highly dependent on the motherboard.
You would think there would be a way of reading what the bios has already read?
 
How about this?

Code:
    Set wbemServices = GetObject("winmgmts:" & "\\localhost\root\wmi")
    Set wbemObjectSet = wbemServices.InstancesOf("MSAcpi_ThermalZoneTemperature")
    
    For Each wbemObject In wbemObjectSet
        stemp = (wbemObject.CurrentTemperature - 2732) / 10
    Next

Gives me a 52.

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Add this:
Code:
    Dim wbemServices As Object
    Dim wbemObject As Object
    Dim wbemObjectSet As Object
    Dim wbemCounter As Integer
    Dim stemp As Single

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Oops. Have to destroy them when you're done.

Code:
    Set wbemServices = Nothing
    Set wbemObjectSet = Nothing

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
This would be a handy tool for me to have as well.

However I have copied and pasted all of the code above into a command button sub. stemp = 27.

Using other software (Everest) I get a CPU temp of 41 C and 106 F. What is wrong?

Also how can the other tempetures such as Mobo temp, HD temp etc be retrieved? What about fan Speeds, how can they be retrieved.
 
I don't know how he came up with the calculation, and just assumed that it was right (for my laptop). It'd be easy to change to get it to match your reading, but who knows which is correct?

You could use Scriptomatic2 to get most of the info that you asked about.

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top