Instantly share code, notes, and snippets.

Embed
What would you like to do?
VBS Script to get the Windows(R) 7 Product Key from a PC's registry.
' VBS Script to get the Windows(R) 7 Product Key from a PC's registry.
'
' Save the VBScript as "getWin7Key.vbs" somewhere on your Windows7 PC.
' Now, when you double-click the local script file an alertbox pops up
' displaying the product key stored in the machine's Windows registry.
Set WshShell = WScript.CreateObject("WScript.Shell")
KeyPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"
MsgBox ExtractKey(WshShell.RegRead(KeyPath))
Function ExtractKey(KeyInput)
Const KeyOffset = 52
i = 28
CharWhitelist = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = KeyInput(x + KeyOffset) + Cur
KeyInput(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x >= 0
i = i -1
KeyOutput = Mid(CharWhitelist, Cur + 1, 1) & KeyOutput
If (((29 - i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = "-" & KeyOutput
End If
Loop While i >= 0
ExtractKey = KeyOutput
End Function
@sunsprite

This comment has been minimized.

Show comment
Hide comment
@sunsprite

sunsprite Dec 2, 2015

Thank you so much! This is much better than using downloaded applications, which gave me concern that my Key would be pirated.

sunsprite commented Dec 2, 2015

Thank you so much! This is much better than using downloaded applications, which gave me concern that my Key would be pirated.

@k00sa

This comment has been minimized.

Show comment
Hide comment
@k00sa

k00sa Jan 22, 2016

Can u explain me how to modify source code to load registry from custom folder. Fox example i exported registry to my C:\user\desktop...
and can i somehow load in that way ? (: or just put hex string from registry to .txt and then read ? (:

k00sa commented Jan 22, 2016

Can u explain me how to modify source code to load registry from custom folder. Fox example i exported registry to my C:\user\desktop...
and can i somehow load in that way ? (: or just put hex string from registry to .txt and then read ? (:

@SinaAnderson

This comment has been minimized.

Show comment
Hide comment
@SinaAnderson

SinaAnderson Jul 28, 2016

Hi,
Thanks for the great code. How do you change it to save/add the output to a text file? I want to run this on my domain computers.
Many thanks,
Sina

SinaAnderson commented Jul 28, 2016

Hi,
Thanks for the great code. How do you change it to save/add the output to a text file? I want to run this on my domain computers.
Many thanks,
Sina

@ffansszi

This comment has been minimized.

Show comment
Hide comment
@ffansszi

ffansszi Oct 12, 2016

Here is another way to find Windows product key: http://www.uukeys.com/find-windows-7-product-key.html

ffansszi commented Oct 12, 2016

Here is another way to find Windows product key: http://www.uukeys.com/find-windows-7-product-key.html

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 30, 2016

To display key in console run cscript.exe get-win7-productkey.vbs
to save it to file: cscript.exe get-win7-productkey.vbs > key.txt

ghost commented Dec 30, 2016

To display key in console run cscript.exe get-win7-productkey.vbs
to save it to file: cscript.exe get-win7-productkey.vbs > key.txt

@ctooth16

This comment has been minimized.

Show comment
Hide comment
@ctooth16

ctooth16 Jan 21, 2017

Perfect!

You can also just click on the MsgBox popup and press CTRL+C and paste the output into a text file.

ctooth16 commented Jan 21, 2017

Perfect!

You can also just click on the MsgBox popup and press CTRL+C and paste the output into a text file.

@cononda

This comment has been minimized.

Show comment
Hide comment
@cononda

cononda Jan 23, 2017

To dawjan
display key in console run cscript.exe get-win7-productkey.vbs
to save it to file: cscript.exe get-win7-productkey.vbs > key.txt

Thanks for this but I get the textfile as follow:
Microsoft (R) Windwos Script Host, Version 5.8
Copyright (R) Microsoft Corporation 1996-2001. Alle Rechte Vorbehalten.

No key written in the file. Any recommendations?

PS running the script only I get the Product Key displayed in a Popupwindows...

cononda commented Jan 23, 2017

To dawjan
display key in console run cscript.exe get-win7-productkey.vbs
to save it to file: cscript.exe get-win7-productkey.vbs > key.txt

Thanks for this but I get the textfile as follow:
Microsoft (R) Windwos Script Host, Version 5.8
Copyright (R) Microsoft Corporation 1996-2001. Alle Rechte Vorbehalten.

No key written in the file. Any recommendations?

PS running the script only I get the Product Key displayed in a Popupwindows...

@tRekiP

This comment has been minimized.

Show comment
Hide comment
@tRekiP

tRekiP Mar 3, 2017

Where i have to write it? Im newbie in these registry and others.. Start -> Registy (some file) -> copy that command -> past here?

tRekiP commented Mar 3, 2017

Where i have to write it? Im newbie in these registry and others.. Start -> Registy (some file) -> copy that command -> past here?

@windowskeys

This comment has been minimized.

Show comment
Hide comment
@windowskeys

windowskeys Mar 7, 2017

For friends who wanna windows 7 product key,visit this page: www.vip4sale.com Fast delivery, and the keys are genuine!

windowskeys commented Mar 7, 2017

For friends who wanna windows 7 product key,visit this page: www.vip4sale.com Fast delivery, and the keys are genuine!

@windowskeys

This comment has been minimized.

Show comment
Hide comment
@windowskeys

windowskeys Mar 15, 2017

Check here: http://www.microsoftonlinekey.com , you will find many CHEAP Microsoft keys.

windowskeys commented Mar 15, 2017

Check here: http://www.microsoftonlinekey.com , you will find many CHEAP Microsoft keys.

@Manskerty

This comment has been minimized.

Show comment
Hide comment
@Manskerty

Manskerty Jun 24, 2017

Never mind , the Windows Password recovery tool may be a effective software for us to solve this problem ,
Here is a tutorial that you can get more steps about how to recover Windows Password :https://www.recoverywindowspassword.com/reset-windows-7-login-password-in-3-ways.html

Manskerty commented Jun 24, 2017

Never mind , the Windows Password recovery tool may be a effective software for us to solve this problem ,
Here is a tutorial that you can get more steps about how to recover Windows Password :https://www.recoverywindowspassword.com/reset-windows-7-login-password-in-3-ways.html

@CristinaHopkins

This comment has been minimized.

Show comment
Hide comment
@CristinaHopkins

CristinaHopkins Sep 8, 2017

Go site http://www.vanskeys.com to get genuine windows key here.

CristinaHopkins commented Sep 8, 2017

Go site http://www.vanskeys.com to get genuine windows key here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment