SerialNumber Windows 11

is this code right for Windows PC to get serial number ?
it’s returning nothing at this time

Dim wmi As New WindowsWMIMBS
// Execute the WMI query for BIOS serial number
If wmi.ConnectServer("root\cimv2") Then
  If wmi.Query("WQL", "SELECT SerialNumber FROM Win32_BIOS") Then
    // Get the serial number if available
    If wmi.NextItem Then
      SerialPC = wmi.GetPropertyString("SerialNumber").Trim
    End If
  End If
End If

Do you get something from this powershell cmd? :

(Get-WmiObject -class Win32_BIOS).SerialNumber

Here I get the Bios Serial of my computer as expected (not the OS Serial)

For the OS I can get the serial ID from this class:

(Get-WmiObject -Class Win32_OperatingSystem).SerialNumber

With this code I guet Shell Timed out

Dim sh As New Shell
sh.Execute("powershell -command ""(Get-WmiObject -Class Win32_OperatingSystem).SerialNumber""")

Dim serialNumber As String = sh.Result.Trim

I didn’t ask you to launch it via Xojo, it was just for you inspect if you got your intended values.

Then use your MBS plugin and read the value as your MBS docs probably explains.

Working on it but yeah I forgot to say that the powershell returned correct values.

1 Like

WMIC is off by default in Win 11. Maybe that is the issue?

1 Like

Nope. He’s using a plugin to access the instrumentation. WMIC wasn’t used in the entire thread. He accessed the value via powershell, so his problem is isolated to his use of the plugin.