如何使用脚本或命令行查看 Windows 10 产品密钥?

admin

有许多工具可以实时系统或脱机计算机的注册表配置单元中提取产品密钥。 此外,这是一个小巧的 Vbscript,可获取当前 Windows 安装的产品密钥-无需第三方程序。 该脚本可在 Windows 7、8 和 Windows 10 上运行。以下是给大家整理的查看 Windows 10 产品密钥的两种方法,希望可以帮助到你哦。

方法1:使用 WMI 命令行或 PowerShell

使用以下 WMI 命令行来修复 Windows 安装的产品密钥。

1
wmic path softwarelicensingservice get OA3xOriginalProductkey

此方法检索存储在计算机的 UEFI/BIOS 中的激活密钥。

请注意,您需要在提升权限/管理员命令提示符窗口中运行上述命令。

或者,如果您使用的是 PowerShell,请在管理 PowerShell 窗口中运行以下命令以了解产品密钥:

1
(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

在某些系统中,上述命令将输出标题 OA3xOriginalProductKey 和下面的空白行,不显示任何产品密钥。 如果设备没有嵌入式激活码/产品密钥,则会发生这种情况。

如果设备具有嵌入式固件激活密钥,它将显示在输出中。 如果输出为空白,则设备没有固件嵌入式激活密钥。 大多数设计为运行 Windows 8 或更高版本的 OEM 提供的设备都将具有固件嵌入式密钥。

方法2:使用脚本

重要:请注意,以下方法只是对 DigitalProductId 注册表值进行解码以获取零售产品密钥。 使用此方法检索的密钥可以是自动生成的通用 Windows 10 密钥(对于从 Windows 7 或 Windows 8 升级为数字授权的系统)。 它也可是您在 Windows 10 安装过程中手动输入的零售版密钥(如果您早先购买了许可证)。 因此,如果您使用的是 Windows 10,建议您优先考虑第一种方法。

将以下代码复制到记事本,并将文件另存为 GetProductKey.vbs。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Option Explicit  
 
Dim objshell,path,DigitalID, Result  
Set objshell = CreateObject("WScript.Shell")
'Set registry key path
Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
'Registry key value
DigitalID = objshell.RegRead(Path & "DigitalProductId")
Dim ProductName,ProductID,ProductKey,ProductData
'Get ProductName, ProductID, ProductKey
ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName")
ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID")
ProductKey = "Installed Key: " & ConvertToKey(DigitalID)  
ProductData = ProductName  & vbNewLine & ProductID  & vbNewLine & ProductKey
'Show messbox if save to a file  
If vbYes = MsgBox(ProductData  & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information"then
   Save ProductData  
End If
 
 
 
'Convert binary to chars
Function ConvertToKey(Key)
    Const KeyOffset = 52
    Dim isWin8, MaPs, i, j, Current, KeyOutput, Last, keypart1, insert
    'Check if OS is Windows 8
    isWin8 = (Key(66\ 6And 1
    Key(66= (Key(66And &HF7) Or ((isWin8 And 2* 4)
    i = 24
    Maps = "BCDFGHJKMPQRTVWXY2346789"
    Do
           Current= 0
        j = 14
        Do
           Current = Current* 256
           Current = Key(j + KeyOffset) + Current
           Key(j + KeyOffset) = (Current \ 24)
           Current=Current Mod 24
            j = j -1
        Loop While j >= 0
        i = i -1
        KeyOutput = Mid(Maps,Current+ 11& KeyOutput
        Last = Current
    Loop While i >= 0  
     
    If (isWin8 = 1Then
        keypart1 = Mid(KeyOutput, 2, Last)
        insert = "N"
        KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 210)
        If Last = 0 Then KeyOutput = insert & KeyOutput
    End If    
     
 
    ConvertToKey = Mid(KeyOutput, 15& "-" & Mid(KeyOutput, 65& "-" & Mid(KeyOutput, 115& "-" & Mid(KeyOutput, 165& "-" & Mid(KeyOutput, 215)
   
     
End Function
'Save data to a file
Function Save(Data)
    Dim fso, fName, txt,objshell,UserName
    Set objshell = CreateObject("wscript.shell")
    'Get current user name  
    UserName = objshell.ExpandEnvironmentStrings("%UserName%")  
    'Create a text file on desktop  
    fName = "C:\Users" & UserName & "\Desktop\WindowsKeyInfo.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txt = fso.CreateTextFile(fName)
    txt.Writeline Data
    txt.Close
End Function


文章版权声明:除非注明,否则均为执刀人的工具库原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog
验证码
评论列表 (暂无评论,205人围观)

还没有评论,来说两句吧...

目录[+]

取消
微信二维码
微信二维码
支付宝二维码