Often users are faced with the need to reinstall licensed Windows. The peculiarity of the operating system installation, in this case, is the need to enter the activation key, without which the system will function with some limitations. What to do if the activation key is lost or the sticker on the laptop is erased? The answer to this question you will find below.
Defining a key using VBScript
Create a text file in any convenient place, for example on your desktop and rename it to WindowsKey.
Open the text file you created earlier in a text editor (Notepad by default) and copy the following code into it:
Set WshShell = CreateObject(“WScript.Shell”)
regKey = “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\”
DigitalProductId = WshShell.RegRead(regKey & “DigitalProductId”)
WinProductName = “Windows Product Name: ” & WshShell.RegRead(regKey & “ProductName”) & vbNewLine
WinProductID = “Windows Product ID: ” & WshShell.RegRead(regKey & “ProductID”) & vbNewLine
WinProductKey = ConvertToKey(DigitalProductId)
strProductKey =”Windows Key: ” & WinProductKey
WinProductID = WinProductName & WinProductID & strProductKey
MsgBox(WinProductKey)
MsgBox(WinProductID)
Function ConvertToKey(regKey)
Const KeyOffset = 52
isWin8 = (regKey(66) \ 6) And 1
regKey(66) = (regKey(66) And &HF7) Or ((isWin8 And 2) * 4)
j = 24
Chars = “BCDFGHJKMPQRTVWXY2346789”
Do
Cur = 0
y = 14
Do
Cur = Cur * 256
Cur = regKey(y + KeyOffset) + Cur
regKey(y + KeyOffset) = (Cur \ 24)
Cur = Cur Mod 24
y = y -1
Loop While y >= 0
j = j -1
winKeyOutput = Mid(Chars, Cur + 1, 1) & winKeyOutput
Last = Cur
Loop While j >= 0
If (isWin8 = 1) Then
keypart1 = Mid(winKeyOutput, 2, Last)
insert = “N”
winKeyOutput = Replace(winKeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
If Last = 0 Then winKeyOutput = insert & winKeyOutput
End If
a = Mid(winKeyOutput, 1, 5)
b = Mid(winKeyOutput, 6, 5)
c = Mid(winKeyOutput, 11, 5)
d = Mid(winKeyOutput, 16, 5)
e = Mid(winKeyOutput, 21, 5)
ConvertToKey = a & “-” & b & “-” & c & “-” & d & “-” & e
End Function
Then press the keyboard shortcut Ctrl+S to save the changes to the file.
Next, change the file extension to .vbs
Now double-click on the WindowsKey.vbs file and a window will pop up with your activation key.
Then click OK button, another window will appear with more detailed information.
Commands to verify activation
slmgr /dli – display license information
slmgr /dlv – display detailed license information
slmgr /xpr – display activation end date
These commands are executed on the command prompt open as administrator.
To display license information, run the slmgr /dli command
The License Details window opens.
To display detailed license information, run the slmgr /dlv command
The License Details window opens.
To display the activation end date, run the slmgr /xpr command
A window will open to display the activation end date.
And some more useful commands:
- slmgr.vbs /rearm – reset activation, return to trial state
- slmgr.vbs /ipk – set product key
- slmgr.vbs /skms – set KMS name or port
- slmgr.vbs /ato – Windows activation
- slmgr.vbs /upk – remove product key
- slmgr.vbs /cpky – remove product key from the registry (anti-theft)