vbscript 获取SQL产品密钥。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 获取SQL产品密钥。相关的知识,希望对你有一定的参考价值。

'.SYNOPSIS
'    Gets SQL product key.
'.DESCRIPTION
'    Gets SQL product key from a binary string array.
'.PARAMETER astrBinaryKey
'    Specifies the obfuscated key.
'.PARAMETER intVersion
'    Specifies the SQL version.
'.EXAMPLE
'    Code.GetSQLProductKey(Fields!SomeField.Value, 12) (SSRS)
'.EXAMPLE
'    GetSQLProductKey({1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0}, 12) (VB.Net)
'.NOTES
'    Created by Ioan Popovici.
'    Credit to Jakob Bindslet and Chrissy LeMaire.
'    I only translated the script in Visual Basic, nothing else.
'.LINK
'    http://mspowershell.blogspot.com/2010/11/sql-server-product-key.html (Jakob Bindslet)
'    https://gallery.technet.microsoft.com/scriptcenter/Get-SQL-Server-Product-4b5bf4f8 (Chrissy LeMaire)
'.LINK
'    https://SCCM.Zone
'.LINK
'    https://SCCM.Zone/Issues
'
'/*##=============================================*/
'/*## SCRIPT BODY                                 */
'/*##=============================================*/
'/* #region FunctionBody */

Function GetSQLProductKey(ByVal astrBinaryKey As String(), ByVal intVersion As Integer) As String
    Dim achrKeyChars As Char() = {"B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", "T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9"}
    Dim strSQLProductKey As String
    Dim iastrBinaryKey As Long
    Dim iachrKeyChars As Long
    Dim iastrBinaryKeyOuterLoop As Long
    Dim iastrBinaryKeyInnerLoop As Long
    Try
        If (intVersion >= 11) Then
            iastrBinaryKey = 0
        Else
            iastrBinaryKey = 52
        End If
        For iastrBinaryKeyOuterLoop = 24 To 0 Step -1
            iachrKeyChars = 0
            For iastrBinaryKeyInnerLoop = 14 To 0 Step -1
                iachrKeyChars = iachrKeyChars * 256 Xor astrBinaryKey(iastrBinaryKeyInnerLoop + iastrBinaryKey)
                astrBinaryKey(iastrBinaryKeyInnerLoop + iastrBinaryKey) = Math.Truncate(iachrKeyChars / 24)
                iachrKeyChars = iachrKeyChars Mod 24
            Next iastrBinaryKeyInnerLoop
            strSQLProductKey = achrKeyChars(iachrKeyChars) + strSQLProductKey
            If (iastrBinaryKeyOuterLoop Mod 5) = 0 And iastrBinaryKeyOuterLoop <> 0 Then
                strSQLProductKey = "-" + strSQLProductKey
            End If
        Next iastrBinaryKeyOuterLoop
    Catch
        strSQLProductKey = "Cannot decode product key."
    End Try
    GetSQLProductKey = strSQLProductKey
End Function

'/* #endregion */
'/*##=============================================*/
'/*## END SCRIPT BODY                             */
'/*##=============================================*/

以上是关于vbscript 获取SQL产品密钥。的主要内容,如果未能解决你的问题,请参考以下文章

sql server产品密钥一定要填吗

请问我在安装SQL Sever 2012时产品密钥一项应该选择啥好咧?

以编程方式获取 Office 2013 产品密钥

sqlserver2016密钥更改

安装SQL server2008时,不能输入密匙 怎么解决

sql 由特定作者导出产品的woocommerce订单电子邮件 - 显示订单已完成日期和变更密钥以及值(如果适用)