vbscript 获取的Windows系统当前序列号

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 获取的Windows系统当前序列号相关的知识,希望对你有一定的参考价值。

Dim s
s = InputBox("当前Windows系统序列号为:", "Windows序列号", GetWindowsSN)
WScript.Quit


'取得当前Windows序列号函数

Function GetWindowsSN()
    Const HKEY_LOCAL_MACHINE = &H80000002
    strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    strValueName = "DigitalProductId"
    strComputer = "."
    Dim iValues()
    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    oReg.GetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, iValues
    Dim arrDPID
    arrDPID = Array()
    For i = 52 To 66
        ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
        arrDPID( UBound(arrDPID) ) = iValues(i)
    Next
    ' <--------------- Create an array to hold the valid characters for a microsoft Product Key -------------------------->
    Dim arrChars
    arrChars = 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")

    ' <--------------- The clever bit !!! (Decrypt the base24 encoded binary data)-------------------------->
    For i = 24 To 0 Step -1
        k = 0
        For j = 14 To 0 Step -1
            k = k * 256 Xor arrDPID(j)
            arrDPID(j) = Int(k / 24)
            k = k Mod 24
        Next
        strProductKey = arrChars(k) & strProductKey
        ' <------- add the "-" between the groups of 5 Char -------->
        If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey
    Next
    GetWindowsSN = strProductKey
End Function

以上是关于vbscript 获取的Windows系统当前序列号的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 获取当前评估行的动态数据

vbscript 获取当前损失描述的日期数据,并测试日期是否已填写

VBScript 的问题 - 作为服务运行时的 RegRead

Windows功能更新1803下的VBSCRIPT速度很慢

如何使用 PowerShell 或 VBScript 获取正在运行的应用程序列表

Windows获取系统当前时间的方式