Get PC Serial Number from Registry

9,936

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

Share:
9,936

Related videos on Youtube

mottmoore
Author by

mottmoore

As an amateur, self-taught programmer, I go against the grain. VBScript is my favorite language to script in, and Powershell is sub-par. I love to learn, and am always asking questions. I swear, every week I reach my question limit.

Updated on September 18, 2022

Comments

  • mottmoore
    mottmoore over 1 year

    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