Skip to content

Instantly share code, notes, and snippets.

@smallfield
Created November 28, 2013 01:54
Show Gist options
  • Save smallfield/7686149 to your computer and use it in GitHub Desktop.
Save smallfield/7686149 to your computer and use it in GitHub Desktop.
Windowsのプロダクトキーを調べるJScript。
function windows_productkey(){
WshShell = new ActiveXObject( "WScript.Shell" );
ret = WshShell.RegRead('HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId');
DigitalProductId = ret.toArray();
hexPid = DigitalProductId.slice( 52, 67 );
decodedChars = Array(24);
digits = 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");
for ( var i=1; i<30;i++ ){
if((i % 6) == 0 ){
decodedChars.push("-");
}
else{
k=0;
for ( var j=14; j>=0;j--){
k = ( k << 8 ) ^ hexPid[j];
hexPid[j] = parseInt( k /digits.length );
k = k % digits.length;
}
decodedChars.push(digits[k]);
}
}
WScript.Echo(decodedChars.reverse().join(""));
}
windows_productkey();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment