Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to get processor id (CPU's ID) using Visual Basic.Net

Author: Shahzad

Some times we do need to find out the cpu's id, which is unique for each CPU. This code example will help you to perform this task in

Import following namespace

Imports System.Management

Declare following three object variables

Dim objMOS As ManagementObjectSearcher

Dim objMOC As Management.ManagementObjectCollection

Dim objMO As Management.ManagementObject

Now, execute the query to get the results

objMOS = New ManagementObjectSearcher("Select * From Win32_Processor")

objMOC = objMOS.Get

Finally, get the CPU's id.

For Each objMO In objMOC

MessageBox.Show("CPU ID = " & objMO("ProcessorID"))


Dispose object variables.


objMOS = Nothing


objMO = Nothing

Article Comments
Hello...I have read about system.Management in many articles that it helps you getting CPU ID. But in my case, i am unable to write system.Management as it gives error that it is not found.can anyone help me.....thanks

Posted on 11/4/2006 8:37:06 AM by Usman Yousaf

You must give reference to your System.Management namespace

Posted on 12/22/2006 12:43:45 AM by sap

you need to add a reference to the form to prior to trying to inport it. Hope that helps!

Posted on 1/30/2007 11:55:11 AM by Paul

Hi usman u have to add reference from explorer -> Reference -> Add Reference -> select system.Managment...Hope it will be useful to u...Bye

Posted on 2/20/2007 2:41:50 AM by Bhavesh

"unable to write system.Management"
In the solution explorer window you point to the line references next press right mouse next choose "add reference.." to add
wish you success.

Posted on 3/16/2007 4:28:21 AM by ckdung

hello... i have to use in web aplication what is the librery i have to use

Posted on 3/29/2007 11:50:00 AM by Carlos Alarcon

hai usman,
go to
>> add referrence
>> select .NET Tab
>> there select System.Management namespace

Posted on 4/3/2007 3:17:35 AM by Mekalaasri

hi usman
you must first add System.Management.dll
in your solution.
to do this:
right click in your solution name in solution explorer and select add referrence and find system.Management.dll in list and add it.

Posted on 4/16/2007 10:06:25 AM by Hossein

You have to add this reference to your project "System.Management"

Posted on 5/2/2007 3:08:13 AM by Javded

You have to add this reference to your project "System.Management", and to add that cpu id is not unique for all pc's

Posted on 5/2/2007 3:08:40 AM by Javded

This best sample to get cpu ID and good lesson for insert system devices .
Sergey Nikulin

Posted on 2/17/2008 12:33:39 AM by Sergey Nikulin

ProcessorID property is not unique for a processor it can be repeated as same for more processors

Posted on 3/6/2008 11:04:51 PM by Yousry

To work properly it needs to add System.Management.dll to project references

Posted on 8/22/2009 2:11:26 PM by maysam

Private Sub GetProcessorID()
Dim objs, obj As Object
objs =GetObject("winmgmts:").InstancesOf("Win32_Processor")
For Each obj In objs
End Sub

This will work on VB6,VB.NET(tested with VS 2008)

Posted on 12/17/2009 3:36:00 AM by Indrajit Ghosh

i use it it works as all cpu with single processor and dual core and core 2 duo processors
but it throw exception not found when it used at my windows application with windows server 2008 at with 8 cpu system
what could i do to get this processor id
i am using ms vs 2010 beta2 .net 4 beta 2

Posted on 2/2/2010 2:50:32 AM by gr8Ashish

Could anybody explain, from where this cpuid is traced...

What is the format of cpuid..why is it 16 characters in length? how can we identify the different vendors from the cpuid? what are the sections in the cpuid..


Posted on 4/1/2010 10:26:02 AM by Ayyappa


I changed "*" in query to "ProcessorId", and it's much faster to me.
So the query became: "Select ProcessorId From Win32_Processor".

Ayyappa: To get the vendor, try "Select Manufacturer From Win32_Processor"

Posted on 4/21/2010 8:44:44 AM by szmg

this working,
thnx dear......

Posted on 4/26/2010 1:31:57 AM by Amia

if i declare System.Management then it is showing the error
please help me if any other dll should be added...?

Posted on 5/21/2010 3:50:43 AM by Vinyas

You can make this code working by adding System.Management.dll First. Then import this name sapce to your application

Posted on 5/21/2010 5:26:01 AM by Nike

Add Article Comment:
Name :
Email Address :
Comments :
<< How to load excel file data into datagrid.

Disclaimer - Privacy
© 2002-2017