Get Windows Serial Number with VB.NET

I'll show you fast and easy way to get operating system serial number that the application is running on. Here how to accomplish this task:

In Page_Load event handler (for example) getting WSN:

Dim MOS As ManagementObjectSearcher = New ManagementObjectSearcher("Select * From Win32_OperatingSystem")
Dim MO As System.Management.ManagementObject
Dim MOC As System.Management.ManagementObjectCollection = MOS.Get
Dim WindowsSerial As String = String.Empty

For Each MO In MOC
   WindowsSerial = MO("SerialNumber")
Next

4 Comments

  • I need Programming

  • don't think it's working well. cos it gives me some errors(not defined) for the first three Dims shown bellow. think you gotta figure it out.

    Dim MOS As ManagementObjectSearcher = New ManagementObjectSearcher("Select * From Win32_OperatingSystem")
    Dim MO As System.Management.ManagementObject
    Dim MOC As System.Management.ManagementObjectCollection = MOS.Get
    Dim WindowsSerial As String = String.Empty

  • You need to add the name space of System.Management to your project!

    In Visual Studio goto Project Menu -> Last Item (Properties)

    Then Select [References]

    Then Click on [Add] and add your System.Management Reference first.

  • i want code in vb.net plz help

Comments have been disabled for this content.