How to Find Windows Product Key via Command in Windows or Linux

Sep 9, 2018 - 43 Comments

How to get a Windows product key

Have you ever needed to find a Windows product key? Maybe you’re troubleshooting a Windows PC, planning on re-installing Windows 10 in a virtual machine, installing on a PC, or installing into Boot Camp on a Mac, or maybe you have a PC computer running Windows that needs the Windows product key for some reason or another.

This article will show you three different ways for how to find a Windows product key directly from Windows itself on the computer, without having to rely on tracking down the Windows product key card from a box, email, or COA. So if you lost or misplaced any of those, don’t worry, the methods covered will work to retrieve the Windows product key directly from Windows 10, Windows 8, Windows 7, or even Linux. And yes if you’re running Windows in Boot Camp on a Mac or in a VM, these tricks work there too.


This article is obviously aimed at users who need their Windows product key for whatever reason. Nonetheless, it’s worth remembering that you can download the Windows 10 ISO directly from Microsoft for free, and you can then use that ISO to create a Windows 10 installer drive for Boot Camp, install Windows 10 into VirtualBox (also free), into Parallels or VMWare, or even for installing on PC hardware. And no, you do not need to activate in order to install Windows 10 from the ISO, nor do you need a product key, but of course there are some limitations with running Windows without activation, of which you can always activate later if needed. Anyway, assuming you have an authorized version of Windows running somewhere and you need the product key, read on to discover three ways to retrieve it.

How to Get the Windows Product Key via cmd in Windows

The simplest way to find the Windows Product Key license is to turn to a privileged command prompt in Windows and execute a command that retrieves the software license product key.

From Windows, open a new Administrator Command Prompt window and then enter the following syntax:

wmic path softwarelicensingservice get OA3xOriginalProductKey

Hit Enter / Return for the Windows product key to be displayed, it is a 25 character alphanumeric string in the format of the following:

XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

That’s it. You can get the Windows product key on nearly any Windows installation using this method.

How to Find Windows Product License Key via Powershell

You can also retrieve a Windows product key from Windows Power Shell with the following command string, entered into a privileged command prompt:

powershell "(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey"

Regardless of which method you use, the product key will be the same (assuming it’s being run on the same installation of Windows anyway).

How to Get Windows Product Key via Linux

You can also get the Windows Product Key from Linux by entering the following privileged command:

sudo cat /sys/firmware/acpi/tables/MSDM | tail -c 32 | xargs -0 echo

Executed correctly with the proper syntax and you’ll find your Windows product key immediately reported back.

This handy linux trick was found on Twitter by @brandonprry and is perfect for users who dual boot Windows and Linux on a computer. And no, in case you were wondering, the linux specific trick does not seem to work from a Mac running Windows in Boot Camp, but if you do know of a method to retrieve a Windows product key used in Boot Camp from Mac OS, share it with us in the comments below.

You can use any of the three methods outlined above to find the Windows product key, obviously two are specific to Windows while the third applies to Linux. There are other options available as well, including using Windows specific utilities like ProduKey which can reveal a Windows product key as well as a Microsoft Office product key, which is quite helpful if you’ve misplaced those as well.

Where can I find the Windows product key usually?

Aside from using the above methods to find a Windows Product Key, the typical places you’d find the 25 digit license key code are; on the COA sticker, in the physical software box, or in an email if you bought Windows digitally.

As you may already know, the most typical place for the Windows product key to be found is on the shiny COA (Certificate of Authenticity) sticker adhered to the enclosure of a Windows PC, whether it’s a laptop or desktop, but maybe that sticker was lost, peeled off, damaged, or never included at all.

If you bought a physical copy of Windows, the product key is typically included in the box itself on a piece of paper, but of course that can be lost or misplaced.

And if you bought Windows digitally, you typically get the product key in an email instead.

But if you’re running Windows in a virtual machine, or on a Mac in Boot Camp, or on a home-built PC or even some laptops, the Certificate of Authenticity sticker for Windows that includes the product key will not be available, and perhaps you long ago lost the email or box containing the product key itself. Or maybe you’re on the road and just don’t have the materials with you, or access to the email or other methods of obtaining the license key. This happens fairly often, regardless of how, where, and why you’re using Windows, which is why it can be so helpful to retrieve the product key directly from software.

Obviously if you don’t use Windows then this will be of no use to you, but Windows remains the most common operating system in corporate, government, and educational environments, and that’s unlikely to change anytime soon. So even if you’re a heavy Mac user or Linux user, you may still be working with Windows from time-to-time, and this can apply to you as well.

If you know of any other tips, tricks, or methods to obtain the Windows product key license number from Windows, Linux, or Mac OS, share them with us in the comments below!

.

Related articles:

Posted by: Paul Horowitz in Tips & Tricks, Troubleshooting

43 Comments

» Comments RSS Feed

  1. Jean-Maurice says:

    Why is the linux command so complicated ? I don’t see the point of piping tail and then echo through xargs, maybe I missed something. A cat command alone would do the job, but for a better reading I’d use strings command, as in

  2. JasonAmber says:

    Thank you for sharing this helpful article on how to find your Windows product key. These are all great options. It’s always good to know that you don’t have to worry about finding a key card if you lose it.

  3. Ayo says:

    Does this work for Windows Server 2019 also?

  4. Windows Server 2019 Product Key can be found at

    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\BackupProductKeyDefault

  5. Ojswi says:

    it is showing invalid query

  6. Mark Williams says:

    Thank you, I had been looking everywhere for this!

  7. joejoe says:

    Thanks! Got my old Windows prod key via the Linux command!!

  8. Nurahiyan says:

    Thank you so much for this method. I was not able to get key through windows don’t know why? U saved me some money…..

  9. Shriram says:

    I am very happy with this simple method to get windows product key. I got my windows product key of windows 8.1.
    Thanks.

  10. Cimri Gezgin says:

    Hi and thank you Paul Horowitz!
    The “How to Get the Windows Product Key via cmd in Windows” method has worked for me in windows 8.1 professional.

    I was looking for any code to run on cmd but people always talking about some .exe files to download. They say on their blogs that the only way to get product key is to download this kind of applications. I did not want to download third party applications to stay away scams. They can steal your product key through these programmes..
    So, I looked for and have found finally and got my key..

    Thank you once more!

  11. Work like a charm. Thanks for sharing

  12. John M says:

    I have a question related to reinstalling Microsoft Windows’ 10.0 in Bootcamp on my MacBookPro.
    Prior to July 2016, I had Windows 7.0 installed in Bootcamp on my MacBook Pro (Mac OS 10.12). I have the the 7.0 Window’s Product Key. I purchased my MacBook Pro in September of 2012.

    I upgraded from Windows 7.0 to Windows 10.0 in July of 2016 (free Microsoft upgrade from 7.0 to 10.0). I down loaded Windows 10.0 from Microsoft.
    I purchase Winclone this past fall with the intent of making a clone of Bootcamp. Before I could make a clone of Bootcamp, I lost the boot-ability of Bootcamp and Windows 10.

    I reinstalled Windows 7.0 in Bootcamp and Bootcamp is currently running on my Mac.

    I would like to put Windows 10.0 back in Bootcamp. I have downloaded an ISO version of Windows 10.0. The problem I have is that I don’t believe I ever received a Product key for Windows 10 and I cannot remember the process of installing Windows 10.0 that I went through back in 2016. I looked through my records and I did get a 10 digit serial/password from Microsoft. The “Product key” for my Windows’ 7.0 CD is 25 digits long.

    I subscribe to the OSXDaily newsletter. I love your tips.
    Any help would be appreciated,

    Thanks,
    John Melin

  13. Julian says:

    Linux. The 3rd option on this article worked for me. #Windows10 Home using VBox

  14. Howard Fupp says:

    Hello – newbie here. Sorry if this is NOT ‘relevant’ thread for discussion — extracting product key from Win 2000 ISO.
    I have a machine running Win2000 Pro — how do I make an ISO off that machine to run under VMWare on another machine [Win7 Pro 64-bit] where I have VMWare Workstation
    running for Win XP ? OR — I have downloaded an ISO for Win2000 already — got to ‘last entries’ for installation, and,
    it wants the 25 char product key. Any help wud be greatly appreciated. Thank you.

  15. Anthony says:

    Both the batch and the powershell works for me (Windows 7 and up) except Windows 8 & 10 Enterprise editions it comes back to the prompt without displaying the Serial Number.

  16. vdiv says:

    Some system info apps fetch the product key. Piriform’s Speccy for example shows it under the Operating System section as the Serial Number.

  17. Eeyoure says:

    Neither of these work for me with Windoze 10 running under Parallels Access. The command prompt returns with a blank.

  18. Bryan says:

    Tried both ways and failed. First option – nothing. Second option a delay then a mass of red info that I did not understand.

    iMac i5 5k 2016 with 16GB memory, High Sierra with Windows 10 pro. All fully up to date.

    Thanks for trying, but failed.

    • Elong Masky says:

      Are you trying in Windows Boot Camp or in Vmware?

      I can confirm it works on native Windows PC.

      It should work on Mac the exact same, there is no difference in Mac with Boot Camp and PC. A Mac is just a PC now with soldered components, running Mac OS, whereas PC is running Windows. This is why Hackintosh is prolific, and so easy now.

      Fascinating reports here keep them up ya’ll.

      • Louie says:

        I tried on boot camp running windows 7 ultimate. Didn’t work. Got the same error I had earlier seen in windows vista home edition on a native windows pc.

  19. Wim F. Abbenhuis says:

    Does not work here either. Win 10 and Parallels. All I get is a new command prompt (Yes, I was in admin-mode).

  20. Remyj says:

    Or you can install the free utility Belarc Advisor which gives you product keys for Windows, Office, and all other licensed packages as well as all your hardware specifics, model, and serial numbers.

    The info from there can be copied and pasted to any document format or can be printed to paper or .PDF file.

  21. walking dad says:

    Doesn’t work to me, either.

  22. Dun says:

    I get the blue screen of death. :)

  23. Rahul says:

    Doesn’t work on Windows 10 :)

  24. Wim F. says:

    Doesn’t work here either. I tried it on Win 10 on Parallels VM; result is just another command prompt.

  25. Zinc Whiskers says:

    CMD and Powershell both returned nothing for me.

    Apparently, if you did the free upgrade from 8.1 you might not have a key at all. Linked to your machine and MS account in the cloud?

    The VB Script I found here did work though.

    https://www.thewindowsclub.com/find-windows-10-product-key-using-vb-script

    • Kent A says:

      Confirmed. Tips in this article produced nothing. The VB Script worked like a charm.

    • ra-mo says:

      wmic must be run as admin command.com or it will not work. right-click on command prompt and run as administrator

      wmic path softwarelicensingservice get OA3xOriginalProductKey

      It works. Do it as directed. right-click command prompt, run as administrator.

      The VBScript works for me as does powershell and wmic command. Windows 10.

      VBScript from Microsoft is:

      Set WshShell = CreateObject("WScript.Shell")
      MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))

      Function ConvertToKey(Key)
      Const KeyOffset = 52
      i = 28
      Chars = "BCDFGHJKMPQRTVWXY2346789"
      Do
      Cur = 0
      x = 14
      Do
      Cur = Cur * 256
      Cur = Key(x + KeyOffset) + Cur
      Key(x + KeyOffset) = (Cur \ 24) And 255
      Cur = Cur Mod 24
      x = x -1
      Loop While x >= 0
      i = i -1
      KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
      If (((29 - i) Mod 6) = 0) And (i -1) Then
      i = i -1
      KeyOutput = "-" & KeyOutput
      End If
      Loop While i >= 0
      ConvertToKey = KeyOutput
      End Function

      from https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_repair/how-to-find-all-windows-version-serial-key/a6d7e4eb-2adf-4e57-8ead-0bd85ec2758d

      wmic path softwarelicensingservice get OA3xOriginalProductKey

      • Louie says:

        Still not working on windows Vista home edition. Not even after I right-click to choose ‘run as administrator’ before I open the command window.

  26. Vic McCartin says:

    Hi, Started with orig. Win8 and updated/graded via invite. Neither approach gives a return. Screen just returns to original prompt.
    Regards

  27. Venkat Kumar says:

    It worked for me on Windows 10 pro. But I need to know how to change Product key locked in BIOS

    • Eloong says:

      Confirmed works in Windows 10, shows the product key.

      As per Venkat question re BIOS, I am not sure how you can change the product key if it is tied to OEM hardware, is it not linked? I believe activation would fail if components changed?

  28. Peter says:

    Does not work for me.

    I tried both of the windows commands on two different windows machines. No error, but no results.

    I tried the linux command on two dual-boot machines, but there was no MSDM in /sys/firmware/acpi/tables

  29. D M says:

    Doesn’t work. I tried it on Win 10 on Parallels VM and all get back was a repeat of part after the “GET”

    • Bryan says:

      I got nothing back when trying first option. With second option after a delay I had a mass of red typing on screen which meant nothing to me. However it was worth a try in case ever needed – thankfully, not needed yet?

  30. D M says:

    Doesn’t work. I tried it on Win 10 on Parallels VM and all get back was a repeat of part after the “GET”

    • Owen says:

      Folks if it is not working for you then it is because you are not running CMD as administrator.

      You can’t open right into CMD, right click and run as administrator, then issue the command.

      It will report your product key.

      • Louie says:

        Nope. At least not on Windows Vista Home Edition 64-bit. I tried right-clicking and choosing to run as administrator and I still get the same error as before.

  31. wariooo says:

    Hey that’s handy. You learn something new every day!

    I had no idea you could get the product key right out of Windows, like most people I used to have a drawer full of product licenses, registration numbers, product keys, license keys, serial numbers. This sure would have been useful back in my days of being a heavy Windows 98, NT, 2000, and XP user! But if it works in Windows 10, Window 7, then I am not sure it would work in Windows XP, despite XP still being widely used.

    I would be interested in finding the same product key information from the Mac side on Boot Camp Windows, is that possible?

    • Louie says:

      I doubt it will work on windows XP. It doesn’t work on windows vista, which is later. At least not on the home edition.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site