Get PC Serial Number from Registry

0

I'm trying to get the serial number of a user's PC from a VBS script, and display it in a msgbox. I am aware of the methods for commandline (wmic bios getserialnumber) and I am aware of the hardware-based methods (like looking at the sticker or the box.) I have checked the registry (HKLM\HARDWARE\DESCRIPTION\System\BIOS) to no avail. How can I use VBS (without calling a batch file) to display a users serial number?

I am moreso looking for a location in the registry for the serial number, I can work the script around that, I just need to know where to look

mottmoore

Posted 2015-09-24T16:28:23.717

Reputation: 21

My serial number does not appear in the registery anywhere, but the wmic command does retrieve it, so you are probably barking up the wrong tree. is the issue that you don;t know how to do the get serialnumber call from within a vbscript without spawning a cmd.exe instance? – Frank Thomas – 2015-09-24T16:53:43.137

1

if you are just looking for the way to do it in VBScript, the code is here: https://support.microsoft.com/en-us/kb/558124 [link updated]

– Frank Thomas – 2015-09-24T16:54:40.437

@FrankThomas You should post that as an answer. – DavidPostill – 2015-09-24T16:58:32.583

Reverse process: search registry with the serial number with RegScanner.

– Biswapriyo – 2017-06-24T08:27:59.237

Answers

1

Here is the VBScript code to find the Serial number of the machine you are using:

    strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystemProduct") 
For Each objItem in colItems 
    msgbox "This Device: " & objItem.IdentifyingNumber, vbOkayOnly, "Serial Number"
Next

This will make a msgbox that displays the serial number in standard format. Thank you all for your help

mottmoore

Posted 2015-09-24T16:28:23.717

Reputation: 21