zoukankan      html  css  js  c++  java
  • Get your Windows product key from a script

    The product key is located in the registry under

    HKLMSoftwareMicrosoftWindows NTCurrentVersion

    It is the value named: DigitalProductId

    If you look at it, you will realize it is encrypted:

    That is what his script takes care of. It reverses the simple XOR encryption and turns that numeric mess into a readable product key.

    cscript serial.vbs

    save the following code to serial.vbs

    '*****************************************
    '* Script Usage: Get Windows Product Key *
    '* http://www.intelliadmin.com           *
    '* Revision 8/15/2012                    *
    '*****************************************
    
    'Constants for our registry query
    const HKEY_LOCAL_MACHINE = &H80000002 
    sRegistryKeyName = "SOFTWAREMicrosoftWindows NTCurrentVersion"
    sRegistryValueName = "DigitalProductId"
    
    function GetProductKey
        'Get the raw product key data 
        dim pValues()
        Set poRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\.
    ootdefault:StdRegProv")
        poRegistry.GetBinaryValue HKEY_LOCAL_MACHINE,sRegistryKeyName,sRegistryValueName,pValues
    
        Dim sArrayPID
        sArrayPID = Array()
    
        'In that data, positions 52-66 contain our product id info
        'We copy to an array so we can decrypt
    
        For i = 52 to 66
            'Increase our array size by one
            ReDim Preserve sArrayPID( UBound(sArrayPID) + 1 )
            'Insert our value into the end if the array
            sArrayPID(UBound(sArrayPID)) = pValues(i)
        Next
    
        'Consants for our product key
        Dim sProductKeyChars
        sProductKeyChars = 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")
    
        For i = 24 To 0 Step -1
            k = 0
            For j = 14 To 0 Step -1
                k = k * 256 Xor sArrayPID(j)
                sArrayPID(j) = Int(k / 24)
                k = k Mod 24
            Next
            sProductKey = sProductKeyChars(k) & sProductKey
            'Adds the - between the key sections
            if i Mod 5 = 0 And i <> 0 Then sProductKey = "-" & sProductKey
        Next
        GetProductKey = sProductKey
    end function
    
    function GetOSVersion
        Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") 
        for each System in SystemSet 
            GetOSVersion = Trim(System.Caption) & " (" & System.Version & ")"
        next 
    end function 
    
    wscript.echo GetOSVersion & ", " & GetProductKey

    reference:

    http://www.intelliadmin.com/index.php/2012/08/get-your-windows-product-key-from-a-script/

  • 相关阅读:
    Java之路---Day09(继承)
    Java之路---Day08
    Java之路---Day07
    Java之路---Day06
    转载:js 创建对象、属性、方法
    Javascript类型检测
    jQuery 如何写插件
    js浮点数精度问题
    IE7.JS解决IE兼容性问题方法
    CSS 中文字体的英文名称 (simhei, simsun) 宋体 微软雅黑
  • 原文地址:https://www.cnblogs.com/zyip/p/3545020.html
Copyright © 2011-2022 走看看