Windows Get Serial Number

From the Windows NT-based (Windows XP and 7 specifically) command prompt, how can I get the serial number of a hard drive as a variable? The one I'm looking at is the serial number of the physical hard disk drive

Canadian Luke

3 Ways to Recover Serial Number in Windows 10 December 10, 2017 December 5, 2017 by Allan Jay Monteclaro Microsoft has made licensing its operating system as comfortable as possible. Feb 14, 2017 - How to find computer serial number. Aplica-se a: Windows Vista EnterpriseWindows Vista BusinessWindows Vista. The following article will help you to find the computer serial number. 'wmic bios get serialnumber'.

Canadian LukeCanadian Luke

4 Answers

vol C:

this will get the volume serial number given to it by windows.

wmic diskdrive get serialnumber

this gets the manufacturers serial number of the hard drive.

MoabMoab
  • What you are looking at is NOT the hard drive serial number.

  • It is called the Volume Serial Number. It is generated at the time of creating and formatting the volume / partition.

  • You can get it by using a command at command prompt : C:> vol c: if C: is the drive you want to retrieve the Volume Serial Number for.

  • All you can do is redirect the output of that command to a file : C:> vol c: > myvol.txt and it will be stored as a text file in your C:

  • I am attaching a screenshot with the highlights:

Windows Get Serial Number
  • The file was stored in the root of C:
  • This is what the myvol.txt file looks like in Notepad:
aliasgaraliasgar

In a batch file one approach is:

  1. VOL command to produce the serial number as text along with text we don't want.
  2. FIND to trim it down to only the line with the serial number.
  3. FOR to grab the 5th token (a part between delimiters) on the line with the serial number.
  4. SET to assign to an environment variable
BrianBrian

In the same vein as Moab's answer, but using PowerShell this time:

What Is My Windows 10 Serial Number

This command gets an instance of the Win32_DiskDrive WMI class and outputs the model of each disk drive in the computer and its corresponding serial number from that instance.

This answer assumes PowerShell 3.0 or later. If running an older version, use Get-WmiObject in place of Get-CimInstance.

What is my windows 10 serial number

On Windows 8 and later, you can also use this command:

bwDracobwDraco

protected by bwDracoFeb 11 '18 at 19:14

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged windowscommand-line or ask your own question.

If you’re planning on doing a reinstall of Windows but can’t find your product key, you’re in luck because it’s stored in the Windows Registry. It’s just not easy to find, and it’s impossible to read without some help. Luckily, we’re here to help.

As you can see in the screenshot above, the product ID is stored in the registry but is in a binary format that can’t be read by humans unless you are some sort of Cylon. You aren’t, are you?

RELATED:Beginner Geek: How to Reinstall Windows on Your Computer

We’re not really sure why Microsoft went to great lengths to make it difficult to see the product keys for their software, especially since they are stored right in there in the registry and can be read by software, if not by humans. We can only assume that they don’t want anybody to re-use a key from an old computer.

The great thing is that you can even recover a key, even from a computer that won’t boot anymore. All you need is access to the disk drive from a working computer. Keep reading for more.

Three Places You Might Find the Key

RELATED:Where to Download Windows 10, 8.1, and 7 ISOs Legally

The key you need will be in one of three places:

  • Stored in software on your PC: When you (or your PC manufacturer) installs Windows, Windows stores its product key in the registry. You can extract this product key, and–often–enter it when reinstalling Windows on your PC. Crucially, you’ll need to grab it from your operating system before you begin reinstalling Windows or it could be deleted if you format your hard drive.
  • Printed on a sticker: Some PCs use a technology called “System Locked Pre-installation,” or SLP. If your PC uses this, the product key on your PC–the one stored in the registry, and the one key-viewer applications display–will be different from the actual key your PC needs. The actual key is on a certificate of authenticity (COA) sticker on your PC or its power supply. The one in the registry and key-viewer application is a red herring. This system was common for Windows 7 PCs.
  • Embedded in your PC’s UEFI firmware: Many newer PCs that come with Windows 8 or 10 use a new method. The key for the version of Windows the PC comes with is stored in the computer’s UEFI firmware or BIOS. You don’t even need to know it–assuming you’re installing the same edition of Windows the PC came with, it should automatically activate and work without you needing to enter a key. It’ll all happen automatically.

Be sure to use the same version and edition of Windows the computer came with. In other words, if it came with Windows 7 Home Premium, you can’t install Windows 7 Professional.

Windows Get Serial Number From Command Line

If the Key Is Stored in Your PC’s Hardware

Let’s start with the simplest situation. On newer Windows 8 and 10 computers, the key isn’t stored in software where it can be wiped, or on a sticker where it could be smudged off or removed. No one can glance at your computer’s sticker to steal its product key. Instead, the key is stored in the computer’s UEFI firmware or BIOS by the manufacturer.

You don’t have to do anything special if you have this. You should just be able to reinstall the same edition of Windows the PC came with and it should just work without even asking you for a key. (Still, it may be best to find the product key using one of the below methods and write it down before reinstalling Windows–just in case.)

If you want to find the UEFI-embedded key and write it down, you can do so quite simply. Just open the Start menu, type “powershell”, and run the Powershell application that comes up.

Then, enter the following command and press Enter:

You should be rewarded with your embedded license key. Write it down and store it in a safe place.

Read the Key From the Certificate of Authenticity Sticker

Number

If you have a Windows 7-era PC, there’s a good chance the PC’s key is a single key the manufacturer uses for all their PCs. Thanks to “System Locked Pre-installation,” you’re not allowed to use that key to install Windows. If you try, you’ll get error messages about the key being invalid.

To check, you’ll need to look for a certificate of authenticity sticker on your computer. The COA sticker verifies that the computer came with an authentic copy of Windows, and that sticker has a product key printed on it. You’ll need that product key to reinstall Windows–and, if the manufacturer used System Locked Pre-installation, that key is different from the one your PC came with in software.

Examine your computer to find the key. On a laptop, it may be on the bottom of the laptop. If your laptop has a removable battery, it may be under the battery. If there’s some sort of compartment you can open, it might be in there. It may even be stuck to the laptop’s charger brick. If it’s a desktop, look on the side of the desktop’s case. If it’s not there, check the top, back, bottom, and anywhere else it might be.

If the key has rubbed off of the sticker, there’s not much you can do. You can try contacting your computer’s manufacturer and explaining what happened, but we can’t guarantee they’ll help. Microsoft would always be happy to sell you another key, though!

Windows Get Serial Number Of Machine

Use NirSoft’s ProduKey to Recover Product Keys (Even if You Can’t Boot the PC)

The easiest way to get access to your product key is with a third-party utility, and there’s nobody better at those than NirSoft. Their utilities are always crapware-free, and are always really useful. The only issue with this particular utility is that some antivirus will detect it as a false positive, because some malware might try to steal your product key.

Note: the NirSoft keyfinder won’t always work for OEM computers, depending on how they decided to activate the licenses. If your OEM installed your computer and used a single key for all their PCs, this won’t work. It also doesn’t work for Office 2013.

All you have to do is download ProduKey, unzip it, and then run it to immediately see all of your product keys. It’s as simple as that.

If you want to recover a key from a dead computer, you can hook up the hard drive to a working PC, and then run ProduKey and use File > Select Source to point to the external Windows directory. You can then grab the keys from that computer easily.

You can also use a Linux live CD to pull the Windows directory off the other computer and onto a thumb drive, or just grab the registry files if you prefer. If you need help, we’ve got a guide to pulling data off a dead computer.

Find the Windows Key Without Any Software (Advanced Users Only)

Assuming you can boot your computer without any problems, you can easily create a simple VBscript that will read the value out of the registry and then translate it into the format that you need for reinstalling. We’re not sure where this script came from, but reader raphoenix posted it on our forum a long time ago, so we’re sharing it here for you.

Copy and paste the following into a Notepad window:

You’ll need to use File -> Save As, change the “Save as type” to “All Files” and then name it productkey.vbs or something similar ending with the vbs extension. We’d recommend saving to the desktop for easy access.

Windows Get Serial Number Cmd

Once you’ve saved it, you can just double-click and the popup window will show you your product key.

Windows Get Serial Number

Pro tip: If you use CTRL+C when the popup window is active, it will copy the contents of the window to the clipboard, and then you can paste it into Notepad or somewhere else.

Windows Get Cpu Serial Number

The product key system is complicated to understand because Microsoft doesn’t really want typical Windows users to reinstall Windows on their PCs. Instead, they’d rather you use your computer manufacturer’s recovery media. But the recovery media is full of the bloatware you don’t want on your PC–that’s why so many geeks often opt to reinstall Windows on their new PCs.