I have created the code for this product key viewer with amazing help from rpgfan3233!!! Thank-you so much for making this possible!!!
Basically, take the below code and put it into a file called anything.hta (or anything.htm).. If you put it in .htm format, you will only be able to run it with Internet Explorer, and you will get a security warning because it interacts with the windows registry. Haven't tested it in .html format on the web, but it does work locally
Here is the code, and have fun (I really hope this helps somebody!!) if you have lost your Product ID, this will definitely be useful for you.
Code:
<HTML>
<input type="hidden" ID="output">
<script Language="VBScript">
// Sets the variables and creates an ActiveX Object for registry reading
Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
// Gets the Digital Product ID from the registry to decode it and turn it into the Product Key
Dim bKey, I, myInt, multiplier
bKey = WshShell.RegRead ("HKLM\Software\Microsoft\Windows NT\CurrentVersion\DigitalProductId")
// Takes the information from the registry key and turns it into a string, useable by JavaScript
Dim OutpVar
OutpVar = ""
For I = UBound(bKey) To LBound(bKey) Step -1
OutpVar = OutpVar & bKey(I)
If Not LBound(bKey)=I Then
OutpVar = OutpVar & ","
End If
Next
// Puts the information from the registry key into a hidden input named "output"
Document.getElementById("output").value = OutpVar
</script>
<script Language="JavaScript">
// This part of the code takes the information from hidden input named "output" and extracts the necessary information
var getVars = document.getElementById("output").value.split(",");
var binaryKey = new Array();
for(i=getVars.length-53;i>getVars.length-68;i--)
{
binaryKey[binaryKey.length] = (getVars[i]*1);
}
// This portion defines the variables for use with the conversion
var digits = ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9'];
var decodedKey = []; //Will be 25 characters at the end.
// This is the real Bread & Butter of the conversion
// Not completely sure how it works, but it does ;)
// Thank-you rpgfan for converting this from the C# language!!!
for (var i = 24; i >= 0; i--) {
var k = 0;
for (var j = binaryKey.length - 1; j >= 0; j--) {
k = (k << 8) + binaryKey[j];
binaryKey[j] = (k / 24) & 255; //The "& 255" converts the
k %= 24; //value to a byte.
}
decodedKey.unshift(digits[k]);
}
// This portion takes the decodedKey array, adds the dashes and puts it in variable ProductKey
var ProductKey = "";
for(i=0;i<decodedKey.length;i++)
{
ProductKey += decodedKey[i];
if(Math.floor((i+1)/5) == (i+1)/5 && i != decodedKey.length-1)
{
ProductKey += "-";
}
}
// Displays the Product Key in an alert message box :D
alert("Your Product Key is:\n"+ProductKey);
</script>
</HTML>
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I will try to see if there is a way to get rid of the VBScript portion, to make it purely JavaScript. Apparently JavaScript cannot read binary data from the registry, so this may not be possible. I just wanna be able to say that JavaScript can do things like this.. JavaScript does currently do the conversion, so that is proof of the powers inside of JavaScript
Thanks for reading, have a nice day!!
EDIT: Not too long ago, I learned the ACTUAL difference between JavaScript and JScript, and this is actually only supported by JScript. JavaScript cannot read from the registry, but JScript can, which is the reason why Internet Explorer works, but other browsers don't. It is also the reason why Internet Explorer is the most unsecure browser out there (not because it is the most popular)
Last edited by TheTeenScripter; 03-02-2009 at 01:49 AM.
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I forgot to mention. This should only work with Windows NT/2000/XP, maybe Vista.. Windows 98/ME have the product key apparently already decoded within the registry. I haven't found information about Win95. I haven't tested this on anything else but XP. Please post about how this performs on your system if you have a version of windows other than XP
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I will try to see if there is a way to get rid of the VBScript portion, to make it purely JavaScript. Apparently JavaScript cannot read binary data from the registry, so this may not be possible. I just wanna be able to say that JavaScript can do things like this.. JavaScript does currently do the conversion, so that is proof of the powers inside of JavaScript
VBscript makes this possible not JavaScript nor JScript.
It is possible with ActiveX (JScript), but user permission is required.
Last edited by Fang; 03-02-2009 at 02:47 AM.
At least 98% of internet users' DNA is identical to that of chimpanzees
VBscript makes this possible not JavaScript nor JScript.
It is possible with ActiveX (JScript), but user permission is required.
I know how it works, I created most of the code.. But, as I was saying, I have tried using JScript to read the binary data inside of the registry key. It failed with an error, type mismatch. It worked with regular values, but not binary ones. It works with VBScript, using the same Windows Scripting Host method, so I used VBScript to read the key and transferred the data to JavaScript through an input element. I will look up more information on why JavaScript will not read the binary data, but until then this is the best I have.
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I can confirm for you it does work in Windows Vista Home Premium 32bit. This is pretty neat, but I have not actually confirmed that it spat out the correct Product Key or not (don't feel like moving my computer right now to find the sticker, which must be on bottom or right side I can't get at right now!). I might check, next time I re-boot, I don't remember if it's shown in the BIOS or not? Anyhow, congrats, cool little project.
Hah! I have found a way to get rid of the VBScript! MSDN does not actually have a JavaScript example for reading binary values from the registry, but I noticed that it outputs it in VBArray format. I was actually looking at the VBArray information in the MSDN website earlier, and it had an example to convert it to a regular (JavaScript) array using .toArray(), I put 2 and 2 together and now it's completely JAVASCRIPT!!!
Now, you have a third (and best yet) method of reading your product key! You can put this directly into a .js file and run it, or use it in the same way originally posted, AWESOME!!! AND THE CODE IS MUCH SHORTER AND CLEANER!!!
Code:
// Grabs the Digital Product ID from the registry and converts it to an array
var shell = new ActiveXObject("WScript.shell");
var DigiProdId = shell.RegRead("HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId");
DigiProdId = DigiProdId.toArray(); // Converts VBArray to regular array, no Visual Basic needed!
// Takes the needed variables out of the array and puts them in another array, binaryKey
var binaryKey = new Array();
for(i=52;i<67;i++)
{
binaryKey[binaryKey.length] = DigiProdId[i];
}
// This portion defines the variables for use with the conversion
var digits = new 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');
var decodedKey = new Array(); // Will be 25 characters at the end
// This is the real Bread & Butter of the conversion
// Not completely sure how it works, but it does ;)
// Thank-you rpgfan for converting this from the C# language!!!
for (var i = 24; i >= 0; i--) {
var k = 0;
for (var j = binaryKey.length - 1; j >= 0; j--) {
k = (k << 8) + binaryKey[j];
binaryKey[j] = (k / 24) & 255; //The "& 255" converts the
k %= 24; //value to a byte.
}
decodedKey.unshift(digits[k]);
}
// This portion takes the decodedKey array, adds the dashes and puts it in variable ProductKey
var ProductKey = "";
for(i=0;i<decodedKey.length;i++)
{
ProductKey += decodedKey[i];
if(Math.floor((i+1)/5) == (i+1)/5 && i != decodedKey.length-1)
{
ProductKey += "-";
}
}
// Displays the Product Key in an popup message box :D
shell.Popup("Your Product Key is:\n"+ProductKey);
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I can confirm for you it does work in Windows Vista Home Premium 32bit. This is pretty neat, but I have not actually confirmed that it spat out the correct Product Key or not (don't feel like moving my computer right now to find the sticker, which must be on bottom or right side I can't get at right now!). I might check, next time I re-boot, I don't remember if it's shown in the BIOS or not? Anyhow, congrats, cool little project.
Thank-you for your feedback, it is very much appreciated!
EDIT: As for the BIOS thing, no it wouldn't be there. The BIOS is just for the motherboard (kinda like firmware), and the Operating System (and thus it's product key) is just software stored on the Hard Drive, but I don't blame you for thinking that because Windows comes with pretty much every PC, and most people think of the BIOS as their "Main PC Settings/Information"
Last edited by TheTeenScripter; 03-02-2009 at 03:56 AM.
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I have been congratulating myself for a good hour now
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I have tested this script to read the Microsoft Office Product Key, and it does (as long as you know where the DigitalProductID is located)
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I have figured out how to use this code to automatically view a key from a windows installation that has crashed!
Basically, using the "reg" command-line utility, you can import the file from %WINDIR%\SYSTEM32\CONFIG\software to any registry key of choice! It is basically just a .hiv file in disguise (so is NTUSER.DAT). You will receive an error message "Access Denied" unless you specify the local computer using it's network name (ex. \\computername\HKLM\Software\OutputKey).
BUT, you can use the Windows Scripting Host inside of an HTML App to load the command behind the scenes and display a waiting screen. Once the reg command has finished, you just use the script as normal, but change the key to be read to HKLM\Software\OutputKey\Microsoft\Windows NT\CurrentVersion\DigitalProductId!!! Once finished, just delete the created key. This has one set-back, though.. Certain keys, once put there, cannot be deleted, and thus your OutputKey cannot be fully deleted, but MOST of the contents can be deleted. I (of course) will try to find a way to overcome this and delete the created keys that currently cannot be deleted.
It is pretty cool though how this turned from a simple "conversion" project to a powerful "you're not so screwed after all" kind of project
Now there without a doubt will be an open-source alternative to getting your Product Key, even if your Operating System doesn't work (but you still have the files)
Now, the only thing left is to find the easiest way to get the file off of the XP Installation folder. I'm thinking of probably including a script that will automatically migrate your activation!!! If only I knew enough about how windows manages driver-files to make a driver backup program
Windows XP Professional
256MB RDRAM (damn expensive)
120GB HD, 2.56GHz P4 Processor
Only 64MB GeForce4 Vid Card /w TV-Out
Wish I had money to buy more RAM lmao
I would like to bump this thread up in order to let more people in on this tool. I was "TheTeenScripter" but i just made that account for the fun of it. On the other hand I have found this to be really useful so if anyone else on here is a computer tech like me, maybe copy & paste for future reference. If not, remember "js product key" because it's #1 in google
Originally Posted by TheTeenScripter
Code:
// Grabs the Digital Product ID from the registry and converts it to an array
var shell = new ActiveXObject("WScript.shell");
var DigiProdId = shell.RegRead("HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId");
DigiProdId = DigiProdId.toArray(); // Converts VBArray to regular array, no Visual Basic needed!
// Takes the needed variables out of the array and puts them in another array, binaryKey
var binaryKey = new Array();
for(i=52;i<67;i++)
{
binaryKey[binaryKey.length] = DigiProdId[i];
}
// This portion defines the variables for use with the conversion
var digits = new 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');
var decodedKey = new Array(); // Will be 25 characters at the end
// This is the real Bread & Butter of the conversion
// Not completely sure how it works, but it does ;)
// Thank-you rpgfan for converting this from the C# language!!!
for (var i = 24; i >= 0; i--) {
var k = 0;
for (var j = binaryKey.length - 1; j >= 0; j--) {
k = (k << 8) + binaryKey[j];
binaryKey[j] = (k / 24) & 255; //The "& 255" converts the
k %= 24; //value to a byte.
}
decodedKey.unshift(digits[k]);
}
// This portion takes the decodedKey array, adds the dashes and puts it in variable ProductKey
var ProductKey = "";
for(i=0;i<decodedKey.length;i++)
{
ProductKey += decodedKey[i];
if(Math.floor((i+1)/5) == (i+1)/5 && i != decodedKey.length-1)
{
ProductKey += "-";
}
}
// Displays the Product Key in an popup message box :D
shell.Popup("Your Product Key is:\n"+ProductKey);
Bookmarks