{"id":5747,"date":"2017-11-07T09:27:10","date_gmt":"2017-11-07T09:27:10","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=5747"},"modified":"2024-04-08T22:18:03","modified_gmt":"2024-04-08T16:48:03","slug":"view-your-product-key-windows-10-8-7-script","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/view-your-product-key-windows-10-8-7-script\/","title":{"rendered":"How to View Your Windows 10 Product Key Using Script or Command-line"},"content":{"rendered":"<p>There are many tools to <a href=\"https:\/\/www.winhelponline.com\/blog\/recover-product-keys-unbootable-windows-pc\/\">extract the Product Key<\/a> from a live system or from the registry hive of an offline computer. Additionally, here is a neat little Vbscript that gets the Product Key of your current Windows installation&#8211;no third-party program required. The script works on Windows 7, 8 and Windows 10.<!--more--><\/p>\n<h2>View Windows 10 Product Key<\/h2>\n<h3>Method 1: Using WMI command-line or PowerShell<\/h3>\n<p>Use the following WMI command-line to fix the product key of your Windows installation.<\/p>\n<pre>wmic path softwarelicensingservice get OA3xOriginalProductKey<\/pre>\n<p>This method retrieves the activation key stored in the UEFI\/BIOS of your computer.<\/p>\n<p>Note that you&#8217;ll need to run the above command from an <a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">elevated\/admin Command Prompt<\/a> window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-17654\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/11\/wmic-product-key.png\" alt=\"wmic path softwarelicensingservice get OA3xOriginalProductKey\" width=\"699\" height=\"186\" \/><\/p>\n<p>Or, if you&#8217;re using PowerShell, run this command from an admin PowerShell window to know the product key:<\/p>\n<pre>(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey<\/pre>\n<p>In some systems, the above commands would output the caption <code>OA3xOriginalProductKey<\/code> and blank rows beneath, showing no product key. This happens if the device doesn&#8217;t have an embedded activation\/product key.<\/p>\n<p>If the device has a firmware-embedded activation key, it will be displayed in the output. If the output is blank, the device does not have a firmware embedded activation key. Most OEM-provided devices designed to run Windows 8 or later will have a firmware-embedded key.<\/p>\n<h3>Method 2: Using Script<\/h3>\n<p><strong>Important:<\/strong> Note that the following method simply decodes the <code>DigitalProductId<\/code> registry value to get the retail product key. The key retrieved using this method could either be the auto-generated <a href=\"https:\/\/www.winhelponline.com\/blog\/windows-10-generic-products-keys-list\/\">generic Windows 10 key<\/a> (for systems upgraded from Windows 7 or 8 under digital entitlement). It could also be the retail edition key (if you bought the license earlier) you entered manually during Windows 10 setup. So, if you&#8217;re using Windows 10, it&#8217;s advisable to give priority to the 1st method.<\/p>\n<p>Copy the following code to Notepad and save the file as GetProductKey.vbs.<\/p>\n<pre>Option Explicit  \r\n \r\nDim objshell,path,DigitalID, Result  \r\nSet objshell = CreateObject(\"WScript.Shell\") \r\n'Set registry key path \r\nPath = \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\\" \r\n'Registry key value \r\nDigitalID = objshell.RegRead(Path &amp; \"DigitalProductId\") \r\nDim ProductName,ProductID,ProductKey,ProductData \r\n'Get ProductName, ProductID, ProductKey \r\nProductName = \"Product Name: \" &amp; objshell.RegRead(Path &amp; \"ProductName\") \r\nProductID = \"Product ID: \" &amp; objshell.RegRead(Path &amp; \"ProductID\") \r\nProductKey = \"Installed Key: \" &amp; ConvertToKey(DigitalID)  \r\nProductData = ProductName  &amp; vbNewLine &amp; ProductID  &amp; vbNewLine &amp; ProductKey \r\n'Show messbox if save to a file  \r\nIf vbYes = MsgBox(ProductData  &amp; vblf &amp; vblf &amp; \"Save to a file?\", vbYesNo + vbQuestion, \"BackUp Windows Key Information\") then \r\n   Save ProductData  \r\nEnd If \r\n \r\n \r\n \r\n'Convert binary to chars \r\nFunction ConvertToKey(Key) \r\n    Const KeyOffset = 52 \r\n    Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert \r\n    'Check if OS is Windows 8 \r\n    isWin8 = (Key(66) \\ 6) And 1 \r\n    Key(66) = (Key(66) And &amp;HF7) Or ((isWin8 And 2) * 4) \r\n    i = 24 \r\n    Maps = \"BCDFGHJKMPQRTVWXY2346789\" \r\n    Do \r\n           Current= 0 \r\n        j = 14 \r\n        Do \r\n           Current = Current* 256 \r\n           Current = Key(j + KeyOffset) + Current \r\n           Key(j + KeyOffset) = (Current \\ 24) \r\n           Current=Current Mod 24 \r\n            j = j -1 \r\n        Loop While j &gt;= 0 \r\n        i = i -1 \r\n        KeyOutput = Mid(Maps,Current+ 1, 1) &amp; KeyOutput \r\n        Last = Current \r\n    Loop While i &gt;= 0  \r\n     \r\n    If (isWin8 = 1) Then \r\n        keypart1 = Mid(KeyOutput, 2, Last) \r\n        insert = \"N\" \r\n        KeyOutput = Replace(KeyOutput, keypart1, keypart1 &amp; insert, 2, 1, 0) \r\n        If Last = 0 Then KeyOutput = insert &amp; KeyOutput \r\n    End If     \r\n     \r\n \r\n    ConvertToKey = Mid(KeyOutput, 1, 5) &amp; \"-\" &amp; Mid(KeyOutput, 6, 5) &amp; \"-\" &amp; Mid(KeyOutput, 11, 5) &amp; \"-\" &amp; Mid(KeyOutput, 16, 5) &amp; \"-\" &amp; Mid(KeyOutput, 21, 5) \r\n    \r\n     \r\nEnd Function \r\n'Save data to a file \r\nFunction Save(Data) \r\n    Dim fso, fName, txt,objshell,UserName \r\n    Set objshell = CreateObject(\"wscript.shell\") \r\n    'Get current user name  \r\n    UserName = objshell.ExpandEnvironmentStrings(\"%UserName%\")  \r\n    'Create a text file on desktop  \r\n    fName = \"C:\\Users\\\" &amp; UserName &amp; \"\\Desktop\\WindowsKeyInfo.txt\" \r\n    Set fso = CreateObject(\"Scripting.FileSystemObject\") \r\n    Set txt = fso.CreateTextFile(fName) \r\n    txt.Writeline Data \r\n    txt.Close \r\nEnd Function\r\n<\/pre>\n<p><small>Source: <a href=\"https:\/\/gist.github.com\/craigtp\/dda7d0fce891a087a962d29be960f1da\" target=\"_blank\" rel=\"noopener noreferrer\">Retrieve Windows Product Key \u00b7 GitHub<\/a><\/small><\/p>\n<p>Double-click to run the script to find out the Product Key of your Windows installation.<\/p>\n<figure id=\"attachment_5748\" aria-describedby=\"caption-attachment-5748\" style=\"width: 690px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5748\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/11\/view-product-key-vbscript.png\" alt=\"vbscript view product key windows 10\" width=\"700\" height=\"275\" \/><figcaption id=\"caption-attachment-5748\" class=\"wp-caption-text\">Product Key retrieved using Vbscript<\/figcaption><\/figure>\n<p>That&#8217;s it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many tools to extract the Product Key from a live system or from the registry hive of an offline computer. Additionally, here is a neat little Vbscript that gets the Product Key of your current Windows installation&#8211;no third-party program required. The script works on Windows 7, 8 and Windows 10.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[7],"tags":[106,396,480],"class_list":["post-5747","post","type-post","status-publish","format-standard","hentry","category-windows","tag-command-prompt","tag-powershell","tag-scripts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3507,"url":"https:\/\/www.winhelponline.com\/blog\/find-windows-installation-date-time\/","url_meta":{"origin":5747,"position":0},"title":"How to Find Windows Installation Date and Time","author":"Ramesh","date":"July 17, 2016","format":false,"excerpt":"You may sometimes think of reinstalling Windows, especially when its performance goes down after a few years due to several different factors. And, you may like to know the date and time of your current Windows installation. This post shows you the different methods using which you can determine the\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"epoch unix time - windows install date and time","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/07\/epoch-unix-install-date.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/07\/epoch-unix-install-date.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/07\/epoch-unix-install-date.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":282,"url":"https:\/\/www.winhelponline.com\/blog\/create-system-restore-point-script-windows-10-8-7-vista-xp\/","url_meta":{"origin":5747,"position":1},"title":"How to Create System Restore Points using Script or Command-Line","author":"Ramesh","date":"May 16, 2008","format":false,"excerpt":"System Restore is a valuable feature in Windows that helps you easily recover the system in the event of any misconfiguration. If you've been using the System Restore feature regularly, then you need to know how to create System Restore Points with a single click using the command-line. You can\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"create restore point wmic shortcut","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/wmic-create-shortcut-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/wmic-create-shortcut-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/wmic-create-shortcut-2.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":8466,"url":"https:\/\/www.winhelponline.com\/blog\/how-to-check-if-a-windows-update-kb-is-installed\/","url_meta":{"origin":5747,"position":2},"title":"How to Check if a Windows Update (KB) is Installed on your Computer?","author":"Ramesh","date":"April 3, 2019","format":false,"excerpt":"The Windows Update channel delivers all necessary updates suitable for your system. Most of the time, manual intervention is not required for installing updates. In some cases, especially during manual installation of an update using standalone installer, you may need to first check if a specific update (a prerequisite update)\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"WinUpdatesView - Windows Updates History Viewer","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/winupdatesview.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/winupdatesview.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/winupdatesview.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3151,"url":"https:\/\/www.winhelponline.com\/blog\/incorrect-uptime-taskmgr-wmi-refresh\/","url_meta":{"origin":5747,"position":3},"title":"Incorrect Uptime Reported by Task Manager and WMI. Refresh it Manually","author":"Ramesh","date":"May 29, 2016","format":false,"excerpt":"Task Manager's Performance tab (CPU section) shows the Uptime information of the system, but you may be wondering why your boot-up time doesn't match the uptime data reported. This is because Task Manager or WMI wouldn't deduct the duration of sleep\/hibernation when calculating uptime. And, with Fast Startup introduced and\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/05\/uptime1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":6699,"url":"https:\/\/www.winhelponline.com\/blog\/brightness-resets-50-percent-after-reboot-windows-10\/","url_meta":{"origin":5747,"position":4},"title":"[Fix] Brightness Resets to 50% After Restarting Windows 10 (v1809)","author":"Ramesh","date":"October 26, 2018","format":false,"excerpt":"After installing Windows 10 feature update v1809, the screen brightness gets reset to 50% after every shutdown or restart. This seems to be yet another bug in the 1809 update. This post tells you how to fix\/workaround the screen brightness reset problem in your Windows 10 1809 computer. [Fix] Brightness\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"powershell set brightness cmdlet task scheduler","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2018\/10\/powershell-screen-brightness-set-prompt.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":28839,"url":"https:\/\/www.winhelponline.com\/blog\/cant-open-cmd-after-uninstalling-python-anaconda\/","url_meta":{"origin":5747,"position":5},"title":"Can&#8217;t Open CMD.exe After Uninstalling Python\/Anaconda; Exit Code 1","author":"Ramesh","date":"September 29, 2022","format":false,"excerpt":"After uninstalling Python\/Anaconda on your Windows computer, Command Prompt may not open. When you run cmd.exe, it flashes on the screen and immediately quits. Also, running DISM and SFC (to repair corrupt system files), repairing Windows installation, and running a thorough malware scan may not fix the issue. Also, when\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"vscode cmd.exe error 1","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/09\/vscode-cmd-error-code-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/5747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=5747"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/5747\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=5747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=5747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=5747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}