2025年4月20日 星期日 乙巳(蛇)年 正月廿一 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 系统应用 > Windows

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

时间:04-26来源:作者:点击数:33

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

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

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

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

  • wmic path softwarelicensingservice get OA3xOriginalProductKey

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

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

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

  • (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。

  • 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) \ 6) And 1
  • Key(66) = (Key(66) And &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+ 1, 1) & KeyOutput
  • Last = Current
  • Loop While i >= 0
  • If (isWin8 = 1) Then
  • keypart1 = Mid(KeyOutput, 2, Last)
  • insert = "N"
  • KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
  • If Last = 0 Then KeyOutput = insert & KeyOutput
  • End If
  • ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)
  • 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
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门