Home » VB.Net

Getting the CPU's temperature in VB 2010 express

If this is possible i'm in need of the code snippet to be able to display the CPU's temperature in a listbox, any help will be appreciated.

7 Answers Found


Answer 1

Get CPU Temperature with VB.net


' Specifies the format the temp should be returned inPublicEnum TempFormat
      ' The CPU temp will be returned in it's raw, uncalculated format
  EndEnum' Gets the current temp of the CPU' <param name="Format">The temp scale the value should be returned in</param>PublicFunction GetCPUTemp(ByVal Format As TempFormat) AsSingleDim enumerator As System.Management.ManagementObjectCollection.ManagementObjectEnumerator
    Dim searcher AsNew System.Management.ManagementObjectSearcher("root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature")
    enumerator = searcher.Get.GetEnumerator()
    While enumerator.MoveNext
      Dim obj As System.Management.ManagementObject = CType(enumerator.Current, System.Management.ManagementObject)
      SelectCase format
        Case TempFormat.Fahrenheit
          ReturnCSng((obj.Item("CurrentTemperature") / 10 - 273.15) * 9 / 5 + 32)
        Case TempFormat.Celsius
          ReturnCSng(obj.Item("CurrentTemperature") / 10 - 273.15)
        Case TempFormat.Kelvin
          ReturnCSng(obj.Item("CurrentTemperature") / 10)
        Case TempFormat.Raw


Answer 2


In addition to Faraz,

There is a fine sample from Martin in this thread.

For both the now given answers you need to set a reference to System.Management and in the sample from Martin also an import for that.

Be aware that for the sample from Faraz you need to set option strict Off



Answer 3

Unfortunately none of the codes i tried in my post and the topic in which Martin posted worked. Im running VB 2010 express  and this may be why, but im not sure, i've decided not to carry on with the project i was doing, how ever feel free to post more code snippets to help others who may need the answer to this question, and i may even come back to this at some point.

Answer 4

Instead of giving up please give the error details here. May be any one here might have encountered that error and have a solution for it.

Answer 5


Thanks for your post.

As Faraz suggested, please try to post the error details, here the forum members will try their best to help you.

In addition, I searched a method about Reading CPU Temperature. Here is the link, please check. Hope it could make you get some ideas.

http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/18ce0701-e87d-4414-a8b5-8be3908a21b8  (Reading CPU Temperature (WMI))

If you have any comments, please feel free to follow up.

Wish you good luck.

Best regards,
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com


Answer 6


The link you gave contains the same code which Martin has given (it is endless times in Microsoft forums).

It is blocked on my Window 7 computer, I thought it was on my computer, because I've not Asus probe installed.

But probably it is something from Windows 7 and Vista 

I saw that more persons are fighting with this, I did not really find a solution.



Answer 7

I tested it before and it worked fine. i tried it on my Desktop and try to run the both code provided above, return the same result

"Not supported" .

After that i downloaded a software Core Temp and it does show's the temperature.

Now i'm pretty sure its manufacturer dependent, since they will be accessed through an I/O port. If you have a specific board you're trying to work with, try looking through the manuals and/or contacting the manufacturer.



I tried to start using VB 2010 Express with a program I originally developed with VB 2005 Express that I moved to VB 2008 Express successfully a couple years ago. It uses a database file (*.mdf) that is on the computer ( not out on a server). When I attempt to run the program in debug mode, I get the following error  "An attempt to attach an auto-named database for file C:\Documents and Settings\Tom\My Documents\Quizzing Stuff\Question Database 2010\QuizQuestionGame\QuizQuestionGame\bin\Release\QuizQuestionDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

I first made a copy of the entire project folder that was working in VB 2008 Express and gave it a different name. In VB2010 I opened the project in the copied folder and it said it successfully converted the project. I am able to open the Data Source in the Designer and see the database structure as I expect. I think the project is still using SQL Server 2005 Express (because it is what is checked in the list of prerequisites on the Publish tab).

Note, I have programmed off and on for many years, but fairly new to using databases and SQL Server. Thanks for any ideas as to the cause and solution?


Hi I was wondering witch one is the best choice Express or Ultimate cause I heared that express has limitaed support for some files but the good thing about it is that its free, so I am lost plus I want something that will enable me to use in the feuture.



I've been through a number of posts dealing with WMI and its ability to report CPU temperature.  I have to say that I'm more confused now than ever. 

Could someone please let me know if WMI is a way to go assuming that I'll be dealing with XP and/or Windows 7 and running on most recent motherboards?

If WMI is not a good option then what are the better options?



I need to to monitor current CPU temperature.  I have looked at WMI but it seems that it does not support it (even with proper providers).

I just wonder how Hmonitor app does it?  The app supports a predefined list of motherboards.  I would not mind locking on a predefined set of motherboards but I'm not sure how to approach it.

Could someone please give me some pointers?




How do i read cpu temperature in windows 7?


I am trying to re write a VB6 program using MS Access, many years ago, using VB 2010 express and SQL server 2008 R2 Express. I have a database with several tables, which I created using the designer. I am able to connect to the database and select data and display it in textboxes etc in vb code. What I have not been able to in code is to INSERT rows DELETE rows or UPDATE any data in the tables. I can do any of these operations using the Query Designer, but I want to do it in code. I can post some code if necessiary, but I thought it might just be some property that I had not set in the designer. I assume that I should be able to do this using the Express editions. I am using Windows 7 64bit.  Thanks in advance for any suggestions.

I am running a third party DLL that generates a SOCKET_ERROR after login when I run in the debugger in 2010 Express.  However the identical code run on 2005 Express does not have the problem.  Also, when I publish the App I do not have the problem running it.  I have already done some intensive coding in the 2010 IDE that I would hate to lose so any insight would be tremendously appreciated. 

Tried thus Far:

Reinstalling 2010 Express VB.NET IDE



I'm using Visual C++ 2010 Express to create a DLL and Visual Basic 2010 Express to call its functions.  In my VC++ DLL (qTest.dll) I have the following function:

DWORD Go_Test(DWORD oddly);


DWORD Go_Test(DWORD oddly)
    if (oddly > 10)
        oddly = 3;
        oddly = 5;

    return oddly;

and the code builds without problems.  In my VB code I have

Public Declare Function Go_Test Lib "qTest.dll" (ByVal oddly As UInt32) As UInt32

and later

Dim odd As UInt32 = 99
Dim pork As UInt32 = 7

odd = Go_Test(pork)

MsgBox("Go_Test is odd at " + Str(odd)) 'if (odd > 10) return 3; else return 5;

But in the VB project when I press <F5> to start debugging / running the program, I get

PInvokeStackImbalance was detected

A call to PInvoke function 'TestPanel!TestPanel.TestPanelModule::Go_Test' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

As you can see, my definition and invocation should match up, everything being a 32-bit unsigned integer, AFAIK.  Thoughts?  Why am I getting this error?




I have been searching high an low amongst the forums on the internet and cant seem to find a solution to my problem. I am hoping someone can help me. I developed an application in VB express 2008 and used the reportviewer with absolutely no problem. I recently got a new laptop and installed VB express 2010. I upraded my project and it seemed to work fine. I now needed to display some more reports so I installed Reportviewer 2010. I tried all the suggestions from the forums to get the control visible. BUT my problem is that no matter what I try, when I drop the control onto the form it puts it into the component section. I have tried opening a brand new project but the same thing happens. Am I missing something. Please help.



I realize it's unlikely, but I want to be sure that the VB Express 2010 installation will not effect my VB6 development environment which is installed on the same computer!





I've found that when trying to compile any program I receive this error on build:

Error    1    The "GenerateResource" task failed unexpectedly.
System.TypeInitializationException: The type initializer for 'Microsoft.Build.Utilities.FileTracker' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Build.Utilities.FileTracker..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Build.Utilities.FileTracker.EnsureFileTrackerOnPath(String rootPath)
   at Microsoft.Build.Tasks.GenerateResource.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

I've tried reinstalling/repairing VS, resetting my settings and changing the target framework with no success. I even tried installing VS on another PC (both are running win 7 Pro 64 bit) only to still receive the same error.

Any assistance would be appreciated



I have downloaded and installed / registered VB 2010 (on a 64bit HP machine). The programme seems to run OK (pictureview tutorial generates code that executes correctly with intellisense etc.)). However the help seems to be missing. When I run manage help settings and choose local help the library location (...\HelpLibrary\)  is greyed out as is the OK button. The HelpLibrary is in ProgramData although there seem to be only mshc and mshi files for VS.

I'm using Visual Basic 2010 Express and I have some troubles with recordsets, specifically using the argument "rs!field". Vb doesn't recognize this code. This is the error "Overload resolution failed because no accessible 'Fields' accepts this number of arguments."


Well I'm a rooky. Please help.


In Visual Basic 2010 Express, after clicking the Help menu and View Help, I get the message, "404, the topic you requested could not be found in local help."  I didn't click any topic.

I tried uninstalling and reinstalling the load program VB_Web.exe, downloaded from Mirosoft, with no change in the help status.

How can I get these help files, and where should I put them.


Thank you, 




I hope I'm in the  right Forum.

Due  to corruption I cant get rid of orphan files from prior version.

No uninstall via control panel!

Is there a way to clean them out?

Thanks for any suggestions




I have a set of individual projects developed in VB 2008 which transfer using ClickOnce to disk and all projects work.  I have transfered all my projects to VB 2010 with no errors recorded but now have problems using the publish function in 2010.

Hardware : Winows 7, x64 bit-based machine, VB 2010 Express

Errors as follows :

1. Cannot publish because a project failed to build.

2. Item ' Microsoft.Net.Framework 3.5 ' could not be located in C:\Program Files (x86)\Microsoft SDKs\Windows\V7.0A\Bootstrapper\

3. The install location for prerequisites has not been set to ' Component Vectors Web site and file Windows Installer 3.1\Windows Installe-KB893803_V2 x86.exe in item Windows Installer 3.1 can not be located on disk.

I need to transfer my projects to Disk using ClickOnce and than onto various desktop machines .

Any help would be greatly appreciated and possible links to documents outlining or explaining the Publish via ClickOnce to Disk process in 2010 Express explained in SIMPLE terms.

Regards and many thanks in advance


The "Add connection" wizard in VB Express 2010's Database Explorer always returns "This file is in use. Enter a new name or close the file that's open in another program." error message, but the file is NOT open in any program.

When I use the same wizard in Visual Web Developer Express 2010, it works fine.

What could possibly be the problem ?


Using : Windows 7 x64 bit based machine VB Express 2010

I have a number of projects referred to as Algebra Set 1, Agebra 1, Algebra 2 etc. which I want to Publish to C:\Algebra via a disk installation.

After Publishing Algebra Set1 and Algebra 1 my C:\Algebra folder shows the following :

Application Files

Algebra 1

Algebra Set 1



Algebra Set 1 is my menu program which list all the other programs and allows access to them via a Button Click code.

I have published Algebra Set 1 with a short cut on the desktop and this works fine but I cannot access say project Algebra 1 with a Button1 Click which uses

Process.Start("C:\Algebra\Algebra 1.appref.ms")

If I use Process.Start("C:\Algebra\") I obtain Windows Explorer showing the folder C:\Algebra but I cannot locate the required file to run Algebra 1.

This is not a problem with the main menu program Algebra set 1 which has a desktop shortcut installed which I can access from an installed program say Algebra 1 via a Button1 Click code :

 Process.Start("C:\Users\Doug\Desktop\Algebra Set 1.appref.ms")

which runs Algebra Set 1 my main menu program.

I do not want to have Desktop shortcuts with any of my programs Algebra 1, Algebra 2 etc as although this will enable me to access them from the Menu Program via a Button Click with ("C:\Users\Doug\Desktop\Algrbra 1,2, etc .appref-ms") as I would clutter up my desktop with shotcuts.

Using the search above the Start Button for Algebra 1 with a right-click to choose Properties  I obtain the location as

C:\Users\Doug\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft

which I cannot use. 

This all works fine in VB Express 2008 with Private Sub Button1_Click etc.Via

   Path=System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu &"\Programs\Algebra 1.appref-ms

I urgently need the code to run my programs out of my main menu program Algebra Set 1 in VB 2010.

Any advise, help would be much appreciated.




1. I didn't understand if after I register VB2010 Express it is free to distribute, published and sale my projects that I wrote in this version?

2. If I upgrade my project from VB2005 Express to VB2010 Express, my project will need a higher framework from version 2.0?

Thank You



I had VB express 2010 beta 2 register since last year and of course I got the message saying that I have to update and re-register.

But it went impossible to uninstall VB express 2010 beta2 and of course the new install of the release VB express 2010 is not possible and stop saying that I have too uninstall completely VB express 2010 beta2!

So I try to take step by step uninstalling Framework, etc.. I even went to regedit and delete all keys in realtion with VB but still.

Now VB express 2010 is not anymore in my list of installed programs but something still blocking the new install.

This is ridiculous!

People like me cannot use VB express 2010 (or even an earlier release) because of this.

I really need VB and i hope there is a solution somewhere to fix this because I need to use VB asap.

I use Windows 7

Thank you very much for your time 


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure