{"id":179,"date":"2016-06-08T10:44:46","date_gmt":"2016-06-08T17:44:46","guid":{"rendered":"http:\/\/vicds.myds.me\/wordpress\/?p=179"},"modified":"2020-08-21T13:17:20","modified_gmt":"2020-08-21T20:17:20","slug":"retrieve-windows-product-key-using-vbscript","status":"publish","type":"post","link":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/","title":{"rendered":"Retrieve Windows Product Key using VBScript"},"content":{"rendered":"\n<p>This VBScript retrieves the <code>ProductID<\/code> from the registry and converts it to the <code>Product Key<\/code> that you entered or one that came pre-installed. &nbsp;Now, you may be wondering, why you would need a script such as this in the first place. &nbsp;Well, what if you need to reactivate Windows or reinstall Windows on your computer and you don&#8217;t have the key handy. &nbsp;The product key is store in the registry but it is stored in binary format so we have to do a little conversion to make it readable.<\/p>\n\n\n\n<p>All you need to do is, copy and paste the following script into Notepad and save the file with any name but the extension should be .vbs (e.g. winkey.vbs). &nbsp;Then just double-click the file to get your product key.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"VBScript\" data-shcb-language-slug=\"vbscript\"><span><code class=\"hljs language-vbscript shcb-wrap-lines\"><span class=\"hljs-keyword\">Set<\/span> WshShell = <span class=\"hljs-built_in\">CreateObject<\/span>(<span class=\"hljs-string\">\"WScript.Shell\"<\/span>)\n<span class=\"hljs-built_in\">MsgBox<\/span> <span class=\"hljs-string\">\"Windows Product Key\"<\/span> &amp; vbnewline &amp; vbnewline &amp; _\nConvertToKey(WshShell.RegRead(<span class=\"hljs-string\">\"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId\"<\/span>))\n\n<span class=\"hljs-keyword\">Function<\/span> ConvertToKey(Key)\n     <span class=\"hljs-keyword\">Const<\/span> KeyOffset = <span class=\"hljs-number\">52<\/span>\n     i = <span class=\"hljs-number\">28<\/span>\n     Chars = <span class=\"hljs-string\">\"BCDFGHJKMPQRTVWXY2346789\"<\/span>\n\n     <span class=\"hljs-keyword\">Do<\/span>\n          Cur = <span class=\"hljs-number\">0<\/span>\n          x = <span class=\"hljs-number\">14<\/span>\n          <span class=\"hljs-keyword\">Do<\/span>\n               Cur = Cur * <span class=\"hljs-number\">256<\/span> \n               Cur = Key(x + KeyOffset) + Cur\n               Key(x + KeyOffset) = (Cur \\ <span class=\"hljs-number\">24<\/span>) <span class=\"hljs-keyword\">And<\/span> <span class=\"hljs-number\">255<\/span>\n               Cur = Cur Mod <span class=\"hljs-number\">24<\/span>\n               x = x - <span class=\"hljs-number\">1<\/span>\n          <span class=\"hljs-keyword\">Loop<\/span> <span class=\"hljs-keyword\">While<\/span> x &gt;= <span class=\"hljs-number\">0<\/span>\n\n          i = i - <span class=\"hljs-number\">1<\/span>\n          KeyOutput = <span class=\"hljs-built_in\">Mid<\/span>(Chars, Cur + <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">1<\/span>) &amp; KeyOutput\n\n          <span class=\"hljs-keyword\">If<\/span> (((<span class=\"hljs-number\">29<\/span> - i) Mod <span class=\"hljs-number\">6<\/span>) = <span class=\"hljs-number\">0<\/span>) <span class=\"hljs-keyword\">And<\/span> (i &lt;&gt; <span class=\"hljs-number\">-1<\/span>) <span class=\"hljs-keyword\">Then<\/span>\n               i = i - <span class=\"hljs-number\">1<\/span>\n               KeyOutput = <span class=\"hljs-string\">\"-\"<\/span> &amp; KeyOutput\n          <span class=\"hljs-keyword\">End<\/span> <span class=\"hljs-keyword\">If<\/span>\n     <span class=\"hljs-keyword\">Loop<\/span> <span class=\"hljs-keyword\">While<\/span> i &gt;= <span class=\"hljs-number\">0<\/span>\n\n     ConvertToKey = KeyOutput\n<span class=\"hljs-keyword\">End<\/span> <span class=\"hljs-keyword\">Function<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">VBScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">vbscript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This VBScript retrieves the ProductID from the registry and converts it to the Product Key that you entered or one that came pre-installed. &nbsp;Now, you &hellip; <\/p>\n","protected":false},"author":1,"featured_media":186,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[40,41,42,39,43],"class_list":["post-179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripts","category-vbs","tag-product-key","tag-vbs","tag-vbscript","tag-windows-key","tag-windows-product-key"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Retrieve Windows Product Key using VBScript - VScrypt<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Retrieve Windows Product Key using VBScript - VScrypt\" \/>\n<meta property=\"og:description\" content=\"This VBScript retrieves the ProductID from the registry and converts it to the Product Key that you entered or one that came pre-installed. &nbsp;Now, you &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\" \/>\n<meta property=\"og:site_name\" content=\"VScrypt\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-08T17:44:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-21T20:17:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"689\" \/>\n\t<meta property=\"og:image:height\" content=\"383\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Vikram\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vikram\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\"},\"author\":{\"name\":\"Vikram\",\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a\"},\"headline\":\"Retrieve Windows Product Key using VBScript\",\"datePublished\":\"2016-06-08T17:44:46+00:00\",\"dateModified\":\"2020-08-21T20:17:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\"},\"wordCount\":137,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.vscrypt.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg\",\"keywords\":[\"product key\",\"vbs\",\"vbscript\",\"windows key\",\"windows product key\"],\"articleSection\":[\"Scripts\",\"VBScripts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\",\"url\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\",\"name\":\"Retrieve Windows Product Key using VBScript - VScrypt\",\"isPartOf\":{\"@id\":\"https:\/\/www.vscrypt.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg\",\"datePublished\":\"2016-06-08T17:44:46+00:00\",\"dateModified\":\"2020-08-21T20:17:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage\",\"url\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg\",\"contentUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg\",\"width\":689,\"height\":383},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vscrypt.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Retrieve Windows Product Key using VBScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vscrypt.com\/#website\",\"url\":\"https:\/\/www.vscrypt.com\/\",\"name\":\"VScrypt\",\"description\":\"Helpful scripts, snippets and guides...\",\"publisher\":{\"@id\":\"https:\/\/www.vscrypt.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vscrypt.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vscrypt.com\/#organization\",\"name\":\"VScrypt\",\"url\":\"https:\/\/www.vscrypt.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png\",\"contentUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png\",\"width\":200,\"height\":80,\"caption\":\"VScrypt\"},\"image\":{\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a\",\"name\":\"Vikram\",\"description\":\"I am just an IT person trying to share as much knowledge as possible hoping someone will find it helpful. It just takes time to organize everything from my head into something that makes sense.\",\"url\":\"https:\/\/www.vscrypt.com\/author\/vchand\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Retrieve Windows Product Key using VBScript - VScrypt","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/","og_locale":"en_US","og_type":"article","og_title":"Retrieve Windows Product Key using VBScript - VScrypt","og_description":"This VBScript retrieves the ProductID from the registry and converts it to the Product Key that you entered or one that came pre-installed. &nbsp;Now, you &hellip;","og_url":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/","og_site_name":"VScrypt","article_published_time":"2016-06-08T17:44:46+00:00","article_modified_time":"2020-08-21T20:17:20+00:00","og_image":[{"width":689,"height":383,"url":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg","type":"image\/jpeg"}],"author":"Vikram","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Vikram","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#article","isPartOf":{"@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/"},"author":{"name":"Vikram","@id":"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a"},"headline":"Retrieve Windows Product Key using VBScript","datePublished":"2016-06-08T17:44:46+00:00","dateModified":"2020-08-21T20:17:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/"},"wordCount":137,"commentCount":0,"publisher":{"@id":"https:\/\/www.vscrypt.com\/#organization"},"image":{"@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg","keywords":["product key","vbs","vbscript","windows key","windows product key"],"articleSection":["Scripts","VBScripts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/","url":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/","name":"Retrieve Windows Product Key using VBScript - VScrypt","isPartOf":{"@id":"https:\/\/www.vscrypt.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage"},"image":{"@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg","datePublished":"2016-06-08T17:44:46+00:00","dateModified":"2020-08-21T20:17:20+00:00","breadcrumb":{"@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#primaryimage","url":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg","contentUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/06\/F09N6G4I6SO1TIT.LARGE1_.jpg","width":689,"height":383},{"@type":"BreadcrumbList","@id":"https:\/\/www.vscrypt.com\/retrieve-windows-product-key-using-vbscript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vscrypt.com\/"},{"@type":"ListItem","position":2,"name":"Retrieve Windows Product Key using VBScript"}]},{"@type":"WebSite","@id":"https:\/\/www.vscrypt.com\/#website","url":"https:\/\/www.vscrypt.com\/","name":"VScrypt","description":"Helpful scripts, snippets and guides...","publisher":{"@id":"https:\/\/www.vscrypt.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vscrypt.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vscrypt.com\/#organization","name":"VScrypt","url":"https:\/\/www.vscrypt.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png","contentUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png","width":200,"height":80,"caption":"VScrypt"},"image":{"@id":"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a","name":"Vikram","description":"I am just an IT person trying to share as much knowledge as possible hoping someone will find it helpful. It just takes time to organize everything from my head into something that makes sense.","url":"https:\/\/www.vscrypt.com\/author\/vchand\/"}]}},"_links":{"self":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/comments?post=179"}],"version-history":[{"count":0,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/posts\/179\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/media\/186"}],"wp:attachment":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}