Wednesday, January 16, 2008

how to programmically get the UUID of your windows machine in vb.net

you need to add reference system.management:

Dim wmiObj As New System.Management.ManagementObjectSearcher("SELECT UUID FROM Win32_ComputerSystemProduct")
Dim objMgmt As System.Management.ManagementObject
For Each objMgmt In wmiObj.Get
MsgBox(objMgmt("UUID").ToString())
Next

2 comments:

  1. Doesn't always work - home-built systems don't have a UUID or it's set to all F's or all 0's.

    ReplyDelete
  2. Interesting, but I guess it still correctly gets the UUID, whatever its set to. Wrap a Try around it just incase its not there if it throws an exception.

    I have some home built machines and they have UUIDs so the actual use of the UUID needs more research.

    ReplyDelete