1

I need to get the product key of my PC using cmd or powershell. How do I get that?

OS Info: Windows 10 64-bit Pro

  • 1
    It is unnecessary to know your Windows 10 product key. What problem are you trying to solve by knowing your product key for Windows 10? One does not simply get the product key with PowerShell, it is more involved, but ShowKeyPlus will show your product key – Ramhound Feb 8 at 15:17
  • Saw this on a another thread awhile ago, works for what i need, but i cant test on Windows 10 non OEM WinRM needs to be enabled warrenheld.com/retrieve-windows-product-keys-network – SQLTemp Feb 8 at 16:28
  • I have found a way to get that! (@SQLTemp WinRm is enabled on my computer :) – Wasif Hasan Feb 8 at 17:02
1

Looks like using using batch or powershell is very tough here. I have found a code in VBScript from https://stackoverflow.com/questions/30255656/vbscript-to-return-windows-product-key

const HKEY_LOCAL_MACHINE = &H80000002

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "DigitalProductId"
strComputer = "."
dim iValues()

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
  strComputer & "\root\default:StdRegProv")
oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,iValues

Dim arrDPID
arrDPID = Array()
For i = 52 to 66
  ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
  arrDPID( UBound(arrDPID) ) = iValues(i)
Next
' <--- Create an array to hold the valid characters for a microsoft Product Key --->
Dim arrChars
arrChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")

' <--- The clever bit !!! (Decrypt the base24 encoded binary data) --->
For i = 24 To 0 Step -1
  k = 0
  For j = 14 To 0 Step -1
    k = k * 256 Xor arrDPID(j)
    arrDPID(j) = Int(k / 24)
    k = k Mod 24
  Next
  strProductKey = arrChars(k) & strProductKey
  ' <--- add the "-" between the groups of 5 Char --->
  If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey
Next
strFinalKey = strProductKey


' <--- This part of the script displays operating system Information and the license Key --->
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
  ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
  strOS   = objOperatingSystem.Caption
  strBuild   = objOperatingSystem.BuildNumber
  strSerial   = objOperatingSystem.SerialNumber
  strRegistered  = objOperatingSystem.RegisteredUser
Next

Set wshShell=CreateObject("wscript.shell")
strPopupMsg = strOS & vbNewLine & vbNewLine
strPopupMsg = strPopupMsg & "Build Number:  " & strBuild & vbNewLine
strPopupMsg = strPopupMsg & "PID:  " & strSerial & vbNewLine & vbNewLine
strPopupMsg = strPopupMsg & "Registered to:  " & strRegistered & vbNewLine & vbNewLine & vbNewLine
strPopupMsg = strPopupMsg & "Your Windows Product Key is:" & vbNewLine & vbNewLine & strFinalKey
strPopupTitle = "Microsoft Windows License Information"
wshShell.Popup strPopupMsg,,strPopupTitle,vbCancelOnly+vbinformation

It messages me the OS version, Product ID, Build version and product key.

| improve this answer | |
  • Confirmed and working! Nice find! Save this text as .vbs and it will just run. – Mikey T.K. Feb 8 at 22:41
  • 1
    Please read How to reference material written by others. You must block quote text that has been written by some else. See Markdown help. I've fixed it for you this time, but please pay attention to this in future. – DavidPostill Feb 8 at 22:50
  • @WasifHasan Clearly this post was not plagiarized as per the original content before David's edit "Looks like using using batch or powershell is very tough here. I have found a code in VBScript from stackoverflow.com/questions/30255656/…".... I assume you were suspended for truly plagiarizing another post; otherwise, seems like you were wrongly accused of something. Welcome to the club if that's the case. A mod will likely delete this comment before you get a chance to oppose to a community manager if this is the post you supposedly "plagiarized". – Pimp Juice IT Feb 9 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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