[.vbs] Windows OEM:SLP Key

Discussion in 'Scripting' started by 38956, Mar 6, 2011.

  1. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    #1 38956, Mar 6, 2011
    Last edited by a moderator: Apr 20, 2017
    [.vbs] Microsoft Windows Product Key Retrieval Script (MWPKRS)

    Microsoft Windows Product Key Retrieval Script (MWPKRS)
    for Windows Version 6.0 ( Vista ) and above!

    This script will retrieve the Windows Product Key.

    • This script should retrieve the product key for Windows version 6 and above
    • To output the txt file to the current users desktop change oFolderPath = 000 to oFolderPath = 101.

    • 21150707.2 - 18:55 Alpha
      • This script has NOT been fully tested.
      • This script has NOT been tested on Windows Vista, 8, or 10
      • Has been tested on Windows 8.1 Pro by s1ave77
      • Removed code for DigitalProductId4



    File: MWPKRS_21150707.2.vbs
    Code:
    ' Microsoft Windows Product Key Retrieval Script (MWPKRS)
    ' WinNT: v6+
    '             21150707.2 - 18:55 Alpha
    
    strMWPKRS = "MWPKRS: 21150707.2 - 18:55 Alpha"
    
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_CURRENT_USER  = &H80000001
    
    Dim objShell
    Dim arrPKey(4)
    
    Set colNamedArguments = WScript.Arguments.Named
    
    strComputer = "."
    strUsername = ""
    strPWD = ""
    
    oFolderPath = 000
    oFileName = "MSWPKRS-PKey.txt" 
    
    strComputer = colNamedArguments.Item("ip")
    strUsername = colNamedArguments.Item("usr")
    strPWD = colNamedArguments.Item("pwd")
    
    strOutput = colNamedArguments.Item("output")
    
            Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
            Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\default", strUsername, strPWD)
            Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUsername, strPWD)
            Set objShell = CreateObject("WScript.Shell")
    
            Set oReg = objSWbemServices.Get("StdRegProv")
            Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    qRegistry
    
    checkWinVer
    
    On Error Resume Next 
    
     WMI_Win32OS
     WMI_SLP
     WMI_SLS
     WMI_Win32CS
    
        Select Case oFolderPath
          Case 000 '* default
    oDirPath    = objShell.CurrentDirectory & "\"
          Case 101 '* SpecialFolders: Desktop
    oDirPath    = arrDesktopFolder(0) & "\"
          Case 201 '* SpecialFolders: AllUsersDesktop
    oDirPath    = arrDesktopFolder(1) & "\"
          Case 102 '* REG HKCU Desktop UserShellFolder
    oDirPath    = arrDesktopFolder(2) & "\"
          Case 103 '* REG HKCU Desktop ShellFolder
    oDirPath    = arrDesktopFolder(3) & "\"
          Case 202 '* REG HKLM CommonDesktop ShellFolder
    oDirPath    = arrDesktopFolder(4) & "\"
          Case Else
    oDirPath    = ".\"
          End Select
    
     If strOutput = "file" Then
          PKeyFile
     End If
    
         PKeyEcho
    
    Sub PKeyEcho
    
       WScript.Echo vbCR _
        & vbTAB & " Microsoft Windows Product Key Retrieval Script (MWPKRS) " & vbCR & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "  Microsoft Windows " & strLicCT & " Product Key" & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "   " & strSLPName & vbCR _
        & "   " & strSLPDesc & vbCR _
        & "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " & vbCR _
        & "Product Name: " & vbTAB & strOSCaption & vbCR _
        & "Edition ID: " & vbTAB & strRegEditionID & vbCR & vbCR _
        & "Product ID: " & vbTAB & vbTAB & strOSSerialNumber & vbCR _   
        & "Product Key: " & vbTAB & vbTAB & "  " & strProductKey & "  " & vbCR _
        & "Partial Product Key: " & vbTAB & vbTAB & strSLPPartialPKey & vbCR & vbCR _
        & "License Family: " & vbTAB & vbTAB & strSLPLicenseFamily & vbCR _
        & "License Channel / Type: " & vbTAB & "  " & strLicChannelType & vbCR _
        & "License Status: "  & vbTAB & vbTAB & strSLPLicenseStatus & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "Additional Product Key(s): " & vbCR & vbCR _
        & " HKLM.WinNT.CV.DigitalProductId:"   & vbTAB & strProductKey & vbCR _
        & " -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  " & vbCR _
        & " WMI.SLP.PartialProductKey: " & vbTAB & vbTAB & strSLPPartialPKey & vbCR _
        & " WMI.SLS.OA3xOriginalProductKey:" & vbTAB & strSLSOA3xOriginalProductKey & vbCR _
        & " -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  " & vbCR _
        & "Internet Explorer \ Registration [ Product Key ]: " & vbCR _
        & " HKLM.MS.IE.Reg.DigitalProductId:"   & vbTAB & strProductKeyIE & vbCR _
        & " -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  " & vbCR _
        & "Default Product Key: " & vbCR _
        & " HKLM.WinNT.CV.DPK.DigitalProductId:"   & vbTAB & strProductKeyDefault & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "WMI.CS.Manufacturer: " & vbTAB & strCSManufacturer & vbCR & vbCR _
        & "OEM Information:" & vbCR _
        & "   Manufacturer:" & vbTAB & vbTAB & strRegOEMInfoManufacturer & vbCR _
        & "   Model:" & vbTAB & vbTAB & vbTAB & strRegOEMInfoModel & vbCR _ 
        & "--------------------------------------------------------------------------------------" & vbCR _
        & Now  & vbTAB & vbTAB & vbTAB & strMWPKRS
    
        exportFilePKEY = MsgBox ("Save to file?" & vbCR & vbCR _ 
          & "File: " & oDirPath & oFileName, vbYesNo, "MWPKRS: Microsoft Windows Product Key > Save to file?")
    
    Select Case exportFilePKEY
    Case 6, vbYes
        PKeyFile
        WScript.Quit
    Case 7, vbNo
        WScript.Quit
      End Select
    
    End Sub
    
    
    Sub PKeyFile
    
    '// Output to File:
    
             Set outputTXT = objFSO.OpenTextFile(oDirPath & oFileName, 2, True)
    
       outputTXT.WriteLine ""
       outputTXT.WriteLine "                 Microsoft Windows Product Key Retrieval Script (MWPKRS)"
       outputTXT.WriteLine ""
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Microsoft Windows " & strLicCT & " Product Key"
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "    " & strSLPName
       outputTXT.WriteLine "    " & strSLPDesc
       outputTXT.WriteLine "    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
       outputTXT.WriteLine "     Product Name: " & vbTAB & vbTAB & strOSCaption
       outputTXT.WriteLine "     Edition ID: " & vbTAB & vbTAB & strRegEditionID
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Product ID: " & vbTAB & vbTAB & strOSSerialNumber
       outputTXT.WriteLine "     Product Key: " & vbTAB & vbTAB & " " & strProductKey
       outputTXT.WriteLine "     Partial Product Key: " & vbTAB & strSLPPartialPKey
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     License Family: " & vbTAB & vbTAB & strSLPLicenseFamily
       outputTXT.WriteLine "     Licence Channel / Type: " & vbTAB & " " & strLicChannelType
       outputTXT.WriteLine "     License Status: " & vbTAB  & vbTAB & strSLPLicenseStatus
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Additional Product Key(s): "
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Registry: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
       outputTXT.WriteLine vbTAB & vbTAB & "DigitalProductId:"   & vbTAB & strProductKey
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     WMI.SLP.PartialProductKey: " & vbTAB & strSLPPartialPKey
       outputTXT.WriteLine "     WMI.SLS.OA3xOriginalProductKey:" & vbTAB & strSLSOA3xOriginalProductKey
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Registry: HKLM\SOFTWARE\Microsoft\Internet Explorer\Registration"
       outputTXT.WriteLine vbTAB & vbTAB & "DigitalProductId:"   & vbTAB & strProductKeyIE
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Registry: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DefaultProductKey"
       outputTXT.WriteLine vbTAB & vbTAB & "DigitalProductId:"   & vbTAB & strProductKeyDefault
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   WMI.CS.Manufacturer: " & vbTAB & strCSManufacturer
       outputTXT.WriteLine ""
       outputTXT.WriteLine "   OEM Information:"
       outputTXT.WriteLine "     Manufacturer:" & vbTAB & vbTAB & strRegOEMInfoManufacturer
       outputTXT.WriteLine "     Model:" & vbTAB & vbTAB & vbTAB & strRegOEMInfoModel 
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   " & Now & vbTAB & vbTAB & vbTAB & vbTAB & strMWPKRS
       WScript.Quit
    End Sub
    
    
    Function checkWinVer
    
    'Check Windows Version :
    
     If Not strRegWinVersion => 6.0 Then
       WScript.Echo "WINDOWS VERSION ERROR:" & vbCR & vbCR _
        & " Microsoft Windows Product Key Retrieval Script (MWPKRS) " & vbCR _
        & "-----------------------------------------------------------------" & vbCR _
        & "  This script requires Windows Version 6.0 ( Vista ) and above!  " & vbCR _
        & "-----------------------------------------------------------------"
       WScript.Quit
     End If
    
    End Function
    
    
     Dim strRegWinVersion, strRegEditionID
     Dim strProductKey
     Dim strProductKeyDefault, strProductKeyIE
     Dim strRegOEMInfoManufacturer, strRegOEMInfoModel
     Dim arrDesktopFolder(4)
    
    Sub qRegistry
    
           keyNTCurrentVersion = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
           keyWinCurrVerOEMInfo = "SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation"
    
       ' Windows
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"CurrentVersion",strRegWinVersion
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"EditionID",strRegEditionID
    
       ' Product Key
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"DigitalProductId",pidBinary
    
            strProductKey = fnDecipherMSKey(pidBinary)
            strPartialPK = Right("0" & strProductKey, 5)
    
    
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion & "\DefaultProductKey","DigitalProductId",pidBinary
    
            strProductKeyDefault = fnDecipherMSKey(pidBinary)
    
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Internet Explorer\Registration","DigitalProductId",pidBinary
    
            strProductKeyIE = fnDecipherMSKey(pidBinary)
    
    
       ' OEM Information
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyWinCurrVerOEMInfo,"Manufacturer",strRegOEMInfoManufacturer
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyWinCurrVerOEMInfo,"Model",strRegOEMInfoModel
    
       ' Shell Folders
             keyHKCRUserShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
              oReg.GetStringValue HKEY_CURRENT_USER,keyHKCRUserShellFolders,"Desktop",strCUserDesktop
             keyHKCRShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
               oReg.GetStringValue HKEY_CURRENT_USER,keyHKCRShellFolders,"Desktop",strCUserDesktopSF
             keyHKLMShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
              oReg.GetStringValue HKEY_LOCAL_MACHINE,keyHKLMShellFolders,"Common Desktop",strCommonDesktopSF
    
             arrDesktopFolder = Array(objShell.SpecialFolders("Desktop"), _
                                      objShell.SpecialFolders("AllUsersDesktop"), _
                                      strCUserDesktop, strCUserDesktopSF, strCommonDesktopSF)
    End Sub
    
    
    Dim strOSCaption, strOSSerialNumber, strOSType
    
    Sub WMI_Win32OS
    
    ' Win32_OperatingSystem:
        Set colOS  = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
    
      For Each objOS in colOS 
    
    ' Set variables gathered from Win32_OperatingSystem class:
    
            strOSCaption = objOS.Caption
            strOSSerialNumber = objOS.SerialNumber
    '        strOSSerialNumberX = Replace(objOS.SerialNumber,"-","XXXXX-",6,1)
            strOSType = objOS.OSType
    Next 
    End Sub
    
    
    Dim strSLPName, strSLPDesc, strSLPLicenseFamily, strSLPPartialPKey
    Dim strLicChannelType, strSLPLicenseStatus
    Dim strLicCT
    
    Sub WMI_SLP
    
    ' SoftwareLicensingProduct:
        Set colSLP = objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingProduct WHERE NOT PartialProductKey = null AND Description > 'Operating System'",,48) 
    
      For Each objSLP in colSLP 
    
    ' Set variables gathered from SoftwareLicensingProduct:
    
            strSLPName = objSLP.Name
            strSLPDesc = objSLP.Description
            strSLPLicenseFamily = objSLP.LicenseFamily
            strSLPPartialPKey = objSLP.PartialProductKey
    
    ' Get License Type / Channel from objSLP.Description:
    
              SLPDescLic = Split(strSLPDesc, ", ")
              strLicCT = Replace(SLPDescLic(1), " channel", "")
    
      Select Case strLicCT
           Case "OEM_DM"           : strLicChannelType = strLicCT & "  |  OEM Digital Marker"
           Case "OEM_SLP"          : strLicChannelType = strLicCT & "  |  OEM SLP"
           Case "OEM_COA_SLP"      : strLicChannelType = strLicCT & "  |  COA : OEM SLP"
           Case "OEM_COA_NSLP"     : strLicChannelType = strLicCT & "  |  COA : OEM System Builder"
           Case "RETAIL"           : strLicChannelType = strLicCT & "  |  Retail"
           Case "VOLUME_MAK"        : strLicChannelType = strLicCT & "  |  Volume MAK"
           Case "VOLUME_KMSCLIENT"  : strLicChannelType = strLicCT & "  |  Volume KMS Client"
           Case "VOLUME_KMS"        : strLicChannelType = strLicCT & "  |  Volume KMS Server"
        Case Else
    strLicChannelType = strLicCT
      End Select
    
    ' Get License Status from SoftwareLicensingProduct:
    
     Const HR_S_OK                                 = 0
    Const HR_ERROR_FILE_NOT_FOUND                 = &H80070002
    Const HR_SL_E_GRACE_TIME_EXPIRED              = &HC004F009
    Const HR_SL_E_NOT_GENUINE                     = &HC004F200
    
      Select Case objSLP.LicenseStatus
           Case "0" strSLPLicenseStatus = "Unlicensed"
           Case "1" strSLPLicenseStatus = "Licensed"
           Case "2" strSLPLicenseStatus = "Out-Of-Box Grace Period"
           Case "3" strSLPLicenseStatus = "Out-Of-Tolerance Grace Period"
           Case "4" strSLPLicenseStatus = "Non-Genuine Grace Period"
           Case "5" strSLPLicenseStatus = "Notification"
     Select Case objSLP.LicenseStatusReason
     Case HR_SL_E_GRACE_TIME_EXPIRED : strSLPLicenseStatus = strSLPLicenseStatus & ", grace time expired [code &HC004F009]"
     Case HR_SL_E_NOT_GENUINE : strSLPLicenseStatus = strSLPLicenseStatus & ", not genuine [code &HC004F200]"
     Case Else : strSLPLicenseStatus = strSLPLicenseStatus + " [code " & objSLP.LicenseStatusReason & "]"
     End Select
           Case "6" strSLPLicenseStatus = "Extended Grace"
        Case Else
    strSLPLicenseStatus = objSLP.LicenseStatus
      End Select
    
    Next
    End Sub
    
    
    Dim strSLSOA3xOriginalProductKey
    
    Sub WMI_SLS
    
    ' SoftwareLicensingService:
        Set colSLS = objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingService",,48) 
    
      For Each objSLS in colSLS 
    
    ' Set variables gathered from SoftwareLicensingService:
     If strRegWinVersion => 6.2 Then
            strSLSOA3xOriginalProductKey = objSLS.OA3xOriginalProductKey
      Else
            strSLSOA3xOriginalProductKey = " {{ Not Applicable }} "
     End If
    Next
    End Sub
    
    
    Dim strCSManufacturer
    
    Sub WMI_Win32CS
    
    ' Win32_ComputerSystem:
        Set colCS  = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48)
    
      For Each objCS in colCS 
    
    ' Set variables gathered from Win32_ComputerSystem class:
    
            strCSManufacturer = objCS.Manufacturer
    Next
    End Sub
    
    Private Function fnDecipherMSKey(BinaryValuePID)
        Const KeyOffset = 52
        isWin8 = (BinaryValuePID(66) \ 6) And 1
        BinaryValuePID(66) = (BinaryValuePID(66) And &HF7) Or ((isWin8 And 2) * 4)
        i = 24
        Chars = "BCDFGHJKMPQRTVWXY2346789"
        Do
            Cur = 0
            X = 14
            Do
                Cur = Cur * 256
                Cur = BinaryValuePID(X + KeyOffset) + Cur
                BinaryValuePID(X + KeyOffset) = (Cur \ 24)
                Cur = Cur Mod 24
                X = X -1
            Loop While X >= 0
            i = i -1
            KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
            Last = Cur
        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
    
         arrPKey(0) = Mid(KeyOutput, 1, 5)
         arrPKey(1) = Mid(KeyOutput, 6, 5)
         arrPKey(2) = Mid(KeyOutput, 11, 5)
         arrPKey(3) = Mid(KeyOutput, 16, 5)
         arrPKey(4) = Mid(KeyOutput, 21, 5)
    
         fnDecipherMSKey = Join(arrPKey,"-")
    End Function
    
    Copy the above code and paste it in notepad then save it as "MWPKRS_21150707.2.vbs" (including quotes)

    • Optional Command line switches
      • /ip:<IP Address>
      • /usr:<Username>
      • /pwd:<Password>
      • /output:file

    Old Script: MWPKRS: 21141228.7 - 19:45 Zulu
    File: MWPKRS_21141228.7.vbs
    Code:
    ' Microsoft Windows Product Key Retrieval Script (MWPKRS)
    ' WinNT: v6+
    '   Script by 38956
    '             21141228.7 - 19:45 Zulu
    
    const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_CURRENT_USER  = &H80000001
    
    Dim objShell
    Dim arrPKey(4)
    Set colNamedArguments = WScript.Arguments.Named
    
    strComputer = "."
    strUsername = ""
    strPWD = ""
    
    oFolderPath = 000
    oFileName = "MSWPKRS-PKey.txt" 
    
    strComputer = colNamedArguments.Item("ip")
    strUsername = colNamedArguments.Item("usr")
    strPWD = colNamedArguments.Item("pwd")
    
    strOutput = colNamedArguments.Item("output")
    
            Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
            Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\default", strUsername, strPWD)
            Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUsername, strPWD)
            Set objShell = CreateObject("WScript.Shell")
    
            Set oReg = objSWbemServices.Get("StdRegProv")
            Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    '// Set variables gathered from the Registry:
    
            keyNTCurrentVersion = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"CurrentVersion",strRegWinVersion
    
    '// // Check Windows Version :
    
     If Not strRegWinVersion => 6.0 Then
       WScript.Echo "WINDOWS VERSION ERROR:" & vbCR & vbCR _
        & " Microsoft Windows Product Key Retrieval Script (MWPKRS) " & vbCR _
        & "-----------------------------------------------------------------" & vbCR _
        & "  This script requires Windows Version 6.0 ( Vista ) and above!  " & vbCR _
        & "-----------------------------------------------------------------"
       WScript.Quit
     End If
    
    '// // Set variables for Windows Product Key:
    
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"DigitalProductId",pidBinary
    
            decodedMSKey = decipherMSKey(pidBinary)
            strProductKey = decodedMSKey
            strPartialPK = Right("0" & strProductKey, 5)
    
    On Error Resume Next 
    
    '// Set WMI connections for scripting against:
    
        Set colOS  = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
        Set colSLP = objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingProduct WHERE NOT PartialProductKey = null",,48) 
        Set colCS  = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48)
    
    '/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '/ Win32_OperatingSystem:
    
    For Each objOS in colOS 
    
    '// Set variables gathered from Win32_OperatingSystem class:
    
            strOSCaption = objOS.Caption
            strOSSerialNumber = objOS.SerialNumber
    '        strOSSerialNumberX = Replace(objOS.SerialNumber,"-","XXXXX-",6,1)
            strOSType = objOS.OSType
    
    Next
    
    '// SoftwareLicensingProduct:
     For Each objSLP in colSLP 
    
    '// // Set variables gathered from SoftwareLicensingProduct:
    
            strSLPDesc = objSLP.Description
            strSLPPartialPKey = objSLP.PartialProductKey
    
    '// // Get License Type / Channel from objSLP.Description:
    
    
           If InStrB(strSLPDesc,"OEM_SLP") <> 0 then 
               strLicTypeChannel = "2 - OEM SLP / OEM_SLP"
               strLicCT = "OEM_SLP"
           ElseIf InStrB(strSLPDesc,"OEM_COA_SLP") <> 0 then 
               strLicTypeChannel = "8 - COA SLP / OEM_COA_SLP"
               strLicCT = "OEM_COA_SLP"
           ElseIf InStrB(strSLPDesc,"OEM_DM") <> 0 then 
               strLicTypeChannel = "    OEM Digital Marker / OEM_DM"
               strLicCT = "OEM_DM"
           ElseIf InStrB(strSLPDesc,"OEM_COA_NSLP") <> 0 then 
               strLicTypeChannel = "3 - OEM System Builder / OEM_COA_NSLP"
               strLicCT = "OEM_COA_NSLP"
           ElseIf InStrB(strSLPDesc,"RETAIL") <> 0 then 
               strLicTypeChannel = "5 - Retail / RETAIL"
               strLicCT = "RETAIL"
           ElseIf InStrB(strSLPDesc,"VOLUME_MAK") <> 0 then 
               strLicTypeChannel = "6 - Volume MAK / VOLUME_MAK"
               strLicCT = "VOLUME_MAK"
           ElseIf InStrB(strDesc,"VOLUME_KMSCLIENT") <> 0 then 
               strLicTypeChannel = "1 - KMS Client / VOLUME_KMSCLIENT"
               strLicCT = "VOLUME_KMSCLIENT"
           ElseIf InStrB(strDesc,"VOLUME_KMS") <> 0 then 
               strLicTypeChannel = "7 - Volume KMS Server / VOLUME_KMS"
               strLicCT = "VOLUME_KMS"
           Else strLicTypeChannel = "Unknown"
               strLicCT = "Unknown"
          End If
    
    '// // Get License Status from SoftwareLicensingProduct:
    
     Const HR_S_OK                                 = 0
    Const HR_ERROR_FILE_NOT_FOUND                 = &H80070002
    Const HR_SL_E_GRACE_TIME_EXPIRED              = &HC004F009
    Const HR_SL_E_NOT_GENUINE                     = &HC004F200
    
      Select Case objSLP.LicenseStatus
           Case "0" strSLPLicenseStatus = "Unlicensed"
           Case "1" strSLPLicenseStatus = "Licensed"
           Case "2" strSLPLicenseStatus = "Out-Of-Box Grace Period"
           Case "3" strSLPLicenseStatus = "Out-Of-Tolerance Grace Period"
           Case "4" strSLPLicenseStatus = "Non-Genuine Grace Period"
           Case "5" strSLPLicenseStatus = "Notification"
     Select Case objSLP.LicenseStatusReason
     Case HR_SL_E_GRACE_TIME_EXPIRED : strSLPLicenseStatus = strSLPLicenseStatus & ", grace time expired [code &HC004F009]"
     Case HR_SL_E_NOT_GENUINE : strSLPLicenseStatus = strSLPLicenseStatus & ", not genuine [code &HC004F200]"
     Case Else : strSLPLicenseStatus = strSLPLicenseStatus + " [code " & objSLP.LicenseStatusReason & "]"
     End Select
           Case "6" strSLPLicenseStatus = "Extended Grace"
        Case Else
    strSLPLicenseStatus = objSLP.LicenseStatus
      End Select
    
    Next
    
    '// ComputerSystem:
     For Each objCS in colCS 
    
    '// // Set variables gathered from SoftwareLicensingProduct:
    
            strCSManufacturer = objCS.Manufacturer
    
    '// Set variables gathered from the Registry:
    
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"EditionID",strRegEditionID
    
    
    Next
    
             keyHKCRUserShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
              oReg.GetStringValue HKEY_CURRENT_USER,keyHKCRUserShellFolders,"Desktop",strCUserDesktop
             keyHKCRShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
               oReg.GetStringValue HKEY_CURRENT_USER,keyHKCRShellFolders,"Desktop",strCUserDesktopSF
             keyHKLMShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
              oReg.GetStringValue HKEY_LOCAL_MACHINE,keyHKLMShellFolders,"Common Desktop",strCommonDesktopSF
    
              arrDesktopFolder = Array(objShell.SpecialFolders("Desktop"),objShell.SpecialFolders("AllUsersDesktop"),strCUserDesktop, strCUserDesktopSF, strCommonDesktopSF)
    
        Select Case oFolderPath
          Case 000 '* default
    oDirPath    = objShell.CurrentDirectory & "\"
          Case 101 '* SpecialFolders: Desktop
    oDirPath    = arrDesktopFolder(0) & "\"
          Case 201 '* SpecialFolders: AllUsersDesktop
    oDirPath    = arrDesktopFolder(1) & "\"
          Case 102 '* REG HKCU Desktop UserShellFolder
    oDirPath    = arrDesktopFolder(2) & "\"
          Case 103 '* REG HKCU Desktop ShellFolder
    oDirPath    = arrDesktopFolder(3) & "\"
          Case 202 '* REG HKLM CommonDesktop ShellFolder
    oDirPath    = arrDesktopFolder(4) & "\"
          Case Else
    oDirPath    = objShell.CurrentDirectory
          End Select
    
     If strOutput = "file" Then
          PKeyFile
     End If
    
         PKeyEcho
    
    Sub PKeyEcho
    
       WScript.Echo vbCR _
        & vbTAB & " Microsoft Windows Product Key Retrieval Script (MWPKRS) " & vbCR _
        & "------------------------------------------------------------------------------------" & vbCR _
        & "  Microsoft Windows " & strLicCT & " Product Key" & vbCR _
        & "------------------------------------------------------------------------------------" & vbCR _
        & "Product Name: " & vbTAB & strOSCaption & vbCR _
        & "Edition ID: " & vbTAB & strRegEditionID & vbCR & vbCR _
        & "Product ID: " & vbTAB & strOSSerialNumber & vbCR _   
        & "Product Key: "  & vbTAB & chr(34) & strProductKey & chr(34) & vbCR _
        & "Partial Product Key: " & vbTAB & strSLPPartialPKey & vbCR & vbCR _
        & "Lic Type / Channel: " & vbTAB & "     " & strLicTypeChannel & vbCR _
        & "License Status: "  & vbTAB & "     " & strSLPLicenseStatus & vbCR & vbCR _
        & "OEM:  " & vbTAB & vbTAB & strCSManufacturer & vbCR _
        & "------------------------------------------------------------------------------------" & vbCR _
        & Now
    
        exportFilePKEY = MsgBox ("Save to file?" & vbCR & vbCR _ 
          & "File: " & oDirPath & oFileName, vbYesNo, "MWPKRS: Microsoft Windows Product Key > Save to file?")
    
    Select Case exportFilePKEY
    Case 6, vbYes
        PKeyFile
        WScript.Quit
    Case 7, vbNo
        WScript.Quit
      End Select
    
    End Sub
    
    
    Sub PKeyFile
    
    '// Output to File:
    
             Set outputTXT = objFSO.OpenTextFile(oDirPath & oFileName, 2, True)
    
       outputTXT.WriteLine ""
       outputTXT.WriteLine "                Microsoft Windows Product Key Retrieval Script (MWPKRS)"
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Microsoft Windows " & strLicCT & " Product Key"
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "     Product Name: " & vbTAB & vbTAB & strOSCaption
       outputTXT.WriteLine "     Edition ID: " & vbTAB & vbTAB & strRegEditionID
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Product ID: " & vbTAB & vbTAB & strOSSerialNumber
       outputTXT.WriteLine "     Product Key: " & vbTAB & vbTAB & chr(34) & " " & strProductKey & " " & chr(34)
       outputTXT.WriteLine "     Partial Product Key: " & vbTAB & strSLPPartialPKey
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Lic Type / Channel: " & vbTAB & strLicTypeChannel
       outputTXT.WriteLine "     License Status: " & vbTAB  & vbTAB & strSLPLicenseStatus
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     OEM:   " & vbTAB & vbTAB & vbTAB & strCSManufacturer
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   " & Now
       WScript.Quit
    End Sub
    
    Function decipherMSKey(BinaryValuePID)
        Const KeyOffset = 52
        isWin8 = (BinaryValuePID(66) \ 6) And 1
        BinaryValuePID(66) = (BinaryValuePID(66) And &HF7) Or ((isWin8 And 2) * 4)
        i = 24
        Chars = "BCDFGHJKMPQRTVWXY2346789"
        Do
            Cur = 0
            X = 14
            Do
                Cur = Cur * 256
                Cur = BinaryValuePID(X + KeyOffset) + Cur
                BinaryValuePID(X + KeyOffset) = (Cur \ 24)
                Cur = Cur Mod 24
                X = X -1
            Loop While X >= 0
            i = i -1
            KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
            Last = Cur
        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
    
         arrPKey(0) = Mid(KeyOutput, 1, 5)
         arrPKey(1) = Mid(KeyOutput, 6, 5)
         arrPKey(2) = Mid(KeyOutput, 11, 5)
         arrPKey(3) = Mid(KeyOutput, 16, 5)
         arrPKey(4) = Mid(KeyOutput, 21, 5)
    
         decipherMSKey = Join(arrPKey,"-")
    
    End Function
    
    Copy the above code and paste it in notepad then save it as "MWPKRS.vbs" (including quotes)

    • Optional Command line switches
      • /ip:<IP Address>
      • /usr:<Username>
      • /pwd:<Password>
      • /output:file

    Old Script: Windows OEM:SLP Key
    This script will get your OEM:SLP Product Key and OEM Manufacturer

    • This should work on Windows version 6 and above that uses an OEM:SLP Product Key
    • Please check the OEM Manufacturer output to make sure its correct

    File: MSWin-OEMSLP-PK.vbs
    Code:
    ' Microsoft Windows OEM:SLP Product Key
    ' WinNT: v6+
    '             21140513.2 - 07:55 Alpha
    
    const HKEY_LOCAL_MACHINE = &H80000002
    
    Dim objFS, objShell
    Dim strXPKey
    Set colNamedArguments = WScript.Arguments.Named
    
    strComputer = "."
    strUsername = ""
    strPWD = ""
    
    strComputer = colNamedArguments.Item("ip")
    strUsername = colNamedArguments.Item("usr")
    strPWD = colNamedArguments.Item("pwd")
    
            Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
            Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\default", strUsername, strPWD)
            Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUsername, strPWD)
            Set objShell = CreateObject("WScript.Shell")
    
            Set oReg = objSWbemServices.Get("StdRegProv")
            Set fso = CreateObject("Scripting.FileSystemObject")
    
    '// Set variables gathered from the Registry:
    
            keyNTCurrentVersion = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"CurrentVersion",strRegWinVersion
    
    '// // Check Windows Version :
    
     If Not strRegWinVersion => 6.0 Then
       WScript.Echo "WINDOWS VERSION ERROR:" & vbCR _
        & "---------------------------------------------------------------" & vbCR _
        & "  This script requires Windows Version 6.0 ( Vista ) and above!" & vbCR _
        & "---------------------------------------------------------------"
       WScript.Quit
     End If
    
    '// // Set variables for Windows Product Key:
    
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"DigitalProductId",pidBinary
    
            strProductKey = GetKey(pidBinary)
            strPartialPK = Right("0" & strProductKey, 5)
    
    On Error Resume Next 
    
    '// Set wMI connections for scripting against:
    
    Set colOS = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_OperatingSystem",,48)
    Set colSLP = objWMIService.ExecQuery( _
        "SELECT * FROM SoftwareLicensingProduct WHERE PartialProductKey = '" & strPartialPK & "'",,48) 
    Set colCS = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_ComputerSystem",,48) 
    
    '/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '/ Win32_OperatingSystem:
    
    For Each objOS in colOS 
    
    '// Set variables gathered from Win32_OperatingSystem class:
    
            strOSCaption = objOS.Caption
            strOSSerialNumber = objOS.SerialNumber
    '        strOSSerialNumberX = Replace(objOS.SerialNumber,"-","XXXXX-",6,1)
            strOSType = objOS.OSType
    
    Next
    
    '// SoftwareLicensingProduct:
     For Each objSLP in colSLP 
    
    '// // Set variables gathered from SoftwareLicensingProduct:
    
            strSLPDesc = objSLP.Description
    
    '// // Get License Type / Channel from objSLP.Description:
    
    
           If InStrB(strSLPDesc,"OEM_SLP") <> 0 then 
               strLicTypeChannel = "2 - OEM SLP / OEM_SLP"
    
           ElseIf InStrB(strSLPDesc,"OEM_COA_SLP") <> 0 then 
               strLicTypeChannel = "8 - COA SLP / OEM_COA_SLP"
    
           ElseIf InStrB(strSLPDesc,"OEM_DM") <> 0 then 
               strLicTypeChannel = "    OEM Digital Marker / OEM_DM"
    
           ElseIf InStrB(strSLPDesc,"OEM_COA_NSLP") <> 0 then 
               strLicTypeChannel = "3 - OEM System Builder / OEM_COA_NSLP"
    
           ElseIf InStrB(strSLPDesc,"RETAIL") <> 0 then 
               strLicTypeChannel = "5 - Retail / RETAIL"
    
           ElseIf InStrB(strSLPDesc,"VOLUME_MAK") <> 0 then 
               strLicTypeChannel = "6 - Volume MAK / VOLUME_MAK"
    
           ElseIf InStrB(strDesc,"VOLUME_KMSCLIENT") <> 0 then 
               strLicTypeChannel = "1 - KMS Client / VOLUME_KMSCLIENT"
    
           ElseIf InStrB(strDesc,"VOLUME_KMS") <> 0 then 
               strLicTypeChannel = "7 - Volume KMS Server / VOLUME_KMS"
    
           Else strLicTypeChannel = "Unknown"
    
          End If
    
    '// // Get License Status from SoftwareLicensingProduct:
    
     Const HR_S_OK                                 = 0
    Const HR_ERROR_FILE_NOT_FOUND                 = &H80070002
    Const HR_SL_E_GRACE_TIME_EXPIRED              = &HC004F009
    Const HR_SL_E_NOT_GENUINE                     = &HC004F200
    
      Select Case objSLP.LicenseStatus
           Case "0" strSLPLicenseStatus = "Unlicensed"
           Case "1" strSLPLicenseStatus = "Licensed"
           Case "2" strSLPLicenseStatus = "Out-Of-Box Grace Period"
           Case "3" strSLPLicenseStatus = "Out-Of-Tolerance Grace Period"
           Case "4" strSLPLicenseStatus = "Non-Genuine Grace Period"
           Case "5" strSLPLicenseStatus = "Notification"
     Select Case objSLP.LicenseStatusReason
     Case HR_SL_E_GRACE_TIME_EXPIRED : strSLPLicenseStatus = strSLPLicenseStatus & ", grace time expired [code &HC004F009]"
     Case HR_SL_E_NOT_GENUINE : strSLPLicenseStatus = strSLPLicenseStatus & ", not genuine [code &HC004F200]"
     Case Else : strSLPLicenseStatus = strSLPLicenseStatus + " [code " & objSLP.LicenseStatusReason & "]"
     End Select
           Case "6" strSLPLicenseStatus = "Extended Grace"
        Case Else
    strSLPLicenseStatus = objSLP.LicenseStatus
      End Select
    
    Next
    
    '// ComputerSystem:
     For Each objCS in colCS 
    
    '// // Set variables gathered from SoftwareLicensingProduct:
    
            strCSManufacturer = objCS.Manufacturer
    
    '// Set variables gathered from the Registry:
    
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"EditionID",strRegEditionID
    
    
    Next
    
     If InStrB(strSLPDesc,"OEM_SLP") > 1 Then
         SLPKeyEcho
       Else
         PKeyEcho
     End if
    
    
    Sub SLPKeyEcho
    
       WScript.Echo "------------------------------------------------------------------------------------" & vbCR _
        & "  Microsoft Windows OEM:SLP Product Key" & vbCR _
        & "------------------------------------------------------------------------------------" & vbCR _
        & "Product Name: " & vbTAB & strOSCaption & vbCR _
        & "Edition ID: " & vbTAB & strRegEditionID & vbCR & vbCR _
        & "Product ID: " & vbTAB & strOSSerialNumber & vbCR _   
        & "Product Key: "  & vbTAB & chr(34) & strProductKey & chr(34) & vbCR & vbCR _
        & "License Status: "  & vbTAB & "     " & strSLPLicenseStatus & vbCR & vbCR _
        & "OEM  " & vbTAB & vbTAB & strCSManufacturer
    
        exportFileSLP = MsgBox ("Save to file?" & vbCR & vbCR _ 
          & "File: .\MSWin-OEMSLP-PK (" & strCSManufacturer & ").txt", vbYesNo, "Microsoft Windows OEM:SLP Product Key > Save to file?")
    
    Select Case exportFileSLP
    Case 6, vbYes
        SLPKeyFile
        WScript.Quit
    Case 7, vbNo
        WScript.Quit
      End Select
    
    End Sub
    
    Sub PKeyEcho
    
       WScript.Echo vbTAB & "          " & " You are NOT using a OEM:SLP Product Key !" & vbCR _
        & "------------------------------------------------------------------------------------" & vbCR _
        & "  Microsoft Windows Product Key" & vbCR _
        & "------------------------------------------------------------------------------------" & vbCR _
        & "Product Name: " & vbTAB & strOSCaption & vbCR _
        & "Edition ID: " & vbTAB & strRegEditionID & vbCR & vbCR _
        & "Product ID: " & vbTAB & strOSSerialNumber & vbCR _   
        & "Product Key: "  & vbTAB & chr(34) & strProductKey & chr(34) & vbCR & vbCR _
        & "Lic Type / Channel: " & vbTAB & "     " & strLicTypeChannel & vbCR _
        & "License Status: "  & vbTAB & "     " & strSLPLicenseStatus & vbCR & vbCR _
    
        exportFilePKEY = MsgBox ("Save to file?" & vbCR & vbCR _ 
          & "File: .\MSWin-PKey.txt", vbYesNo, "Microsoft Windows Product Key > Save to file?")
    
    Select Case exportFilePKEY
    Case 6, vbYes
        PKeyFile
        WScript.Quit
    Case 7, vbNo
        WScript.Quit
      End Select
    
    End Sub
    
    
    Sub SLPKeyFile
    
    '// Output to File:
    
             Set outputTXT = fso.OpenTextFile(".\MSWin-OEMSLP-PK (" & strCSManufacturer & ").txt", 2, True)
    
       outputTXT.WriteLine ""
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Microsoft Windows OEM:SLP Product Key"
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Product Name: " & vbTAB & strOSCaption
       outputTXT.WriteLine "   Edition ID: " & vbTAB & vbTAB & strRegEditionID
       outputTXT.WriteLine ""
       outputTXT.WriteLine "   Product ID: " & vbTAB & vbTAB & strOSSerialNumber
       outputTXT.WriteLine "   Product Key: " & vbTAB & chr(34) & strProductKey & chr(34)
       outputTXT.WriteLine "   License Status: "  & vbTAB & strSLPLicenseStatus
       outputTXT.WriteLine ""
       outputTXT.WriteLine "   OEM  " & vbTAB & vbTAB & strCSManufacturer
    
    End Sub
    
    Sub PKeyFile
    
    '// Output to File:
    
             Set outputTXT = fso.OpenTextFile(".\MSWin-PKey.txt", 2, True)
    
       outputTXT.WriteLine ""
       outputTXT.WriteLine "" & vbTAB & vbTAB & " You are NOT using a OEM:SLP Product Key !"
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Microsoft Windows Product Key"
       outputTXT.WriteLine "  ------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Product Name: " & vbTAB & strOSCaption
       outputTXT.WriteLine "   Edition ID: " & vbTAB & vbTAB & strRegEditionID
       outputTXT.WriteLine ""
       outputTXT.WriteLine "   Product ID: " & vbTAB & vbTAB & strOSSerialNumber
       outputTXT.WriteLine "   Product Key: " & vbTAB & chr(34) & strProductKey & chr(34)
       outputTXT.WriteLine ""
       outputTXT.WriteLine "   Lic Type / Channel: " & vbTAB & strLicTypeChannel
       outputTXT.WriteLine "   License Status: "  & vbTAB & strSLPLicenseStatus
    
    End Sub
    
    Function GetKey(Key)
        Const KeyOffset = 52
        isWin8 = (Key(66) \ 6) And 1
        Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4)
        i = 24
        Chars = "BCDFGHJKMPQRTVWXY2346789"
        Do
            Cur = 0
            X = 14
            Do
                Cur = Cur * 256
                Cur = Key(X + KeyOffset) + Cur
                Key(X + KeyOffset) = (Cur \ 24)
                Cur = Cur Mod 24
                X = X -1
            Loop While X >= 0
            i = i -1
            KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
            Last = Cur
        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
        a = Mid(KeyOutput, 1, 5)
        b = Mid(KeyOutput, 6, 5)
        c = Mid(KeyOutput, 11, 5)
        d = Mid(KeyOutput, 16, 5)
        e = Mid(KeyOutput, 21, 5)
        GetKey = a & "-" & b & "-" & c & "-" & d & "-" & e
    End Function
    

    Copy the above code and paste it in notepad then save it as "MSWin-OEMSLP-PK.vbs" (including quotes)

    Code:
    Code:
      ----------------------------------------------------------------------------
       Microsoft Windows OEM:SLP Product Key
      ----------------------------------------------------------------------------
       Product Name: < Product Name > 
       Edition ID: < Edition ID >
    
       Product ID: < Product ID >
       Product Key: "< Product Key >"
    
       OEM  < OEM Manufacturer >
    
    
    Code:
    Code:
     You are NOT using a OEM:SLP Product Key !
      ------------------------------------------------------------------------------------
       Microsoft Windows Product Key
      ------------------------------------------------------------------------------------
       Product Name: Microsoft Windows 8 Release Preview with Media Center
       Edition ID: ProfessionalWMC
    
       Product ID: 00137-32510-06502-AB346
       Product Key: "MBFBV-W3DP2-2MVKN-PJCQD-KKTF7"
    
       Lic Type / Channel: 5 - Retail / RETAIL
    
    Optional Command line switches

    /ip:<IP Address>
    /usr:<Username>
    /pwd:<Password>



    This script now works with Windows 8 (Windows 8 Release Preview / Windows 8.x RTM)

    • Product Key Function Code Updated (Issue with Win8 Product Keys containing "N" in the key) ## 13-May-2014
    • Minor update OEM_DM (Windows 8) [Lic Type / Channel:] ## 14-Oct-2013
    • Function Code Updated - Thanks to DAZ
     
  2. vivek.krishnan

    vivek.krishnan MDL Novice

    Dec 13, 2009
    48
    7
    0
    Nice.

    I think you meant excluding quotes.
     
  3. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    I put including quotes to make sure users save it as a .vbs (VB Script) file (OEM-SLP-PK_File.vbs) not a text file (OEM-SLP-PK_File.vbs.txt)
     
  4. NCS

    NCS MDL Member

    Jun 24, 2010
    133
    28
    10
    oem slip

    works great...thanks
     
  5. BaWFrAgOr

    BaWFrAgOr MDL Novice

    Jul 31, 2011
    17
    1
    0
    nice it's good
     
  6. moka12345

    moka12345 MDL Novice

    Oct 3, 2011
    5
    0
    0
    nice script , got my key recovered
     
  7. Kido

    Kido MDL Junior Member

    Oct 2, 2011
    83
    4
    0
    WoW! Nice script :worthy:
     
  8. troller

    troller MDL Novice

    Feb 19, 2012
    5
    0
    0
    Very cool.
     
  9. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    Updated script - 21120508.2 - 23:32 Alpha
     
  10. levin91e

    levin91e MDL Novice

    May 9, 2012
    25
    3
    0
    many thanks for scripting this?
     
  11. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    18,681
    18,589
    340
    Time for little correction; works on Windows 8.x RTM.

    ;)
     
  12. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    21131014.1

    21131014.1 : Updated code

    added OEM_DM to Lic Type / Channel for Windows 8 ## 14-Oct-2013
     
  13. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    21140513.2

    21140513.2 : Updated code

    updated product key function code | Issue with keys containing "N" [Win8]
     
  14. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    18,681
    18,589
    340
    So it requires name change now, not only OEM:SLP is supported.

    :biggrin:
     
  15. Dos_Probie

    Dos_Probie MDL Senior Member

    Jul 18, 2012
    250
    86
    10
    Thanks, nice script..Can you have it output the .txt file to desktop and not the current directory?
    Thanks, DP
     
  16. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    [.vbs] Microsoft Windows Product Key Retrieval Script (MWPKRS)

    Microsoft Windows Product Key Retrieval Script (MWPKRS)

    Script renamed and updated.
     
  17. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    #17 38956, Dec 29, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Microsoft Windows Product Key Retrieval Script (MWPKRS) | 21150705.7

    Microsoft Windows Product Key Retrieval Script (MWPKRS)


    MWPKRS: 21150705.7 - 16:34 Alpha
    • Updated and requires testing on Windows 8 and Vista.
    • Has NOT been tested on Windows 10


    File: MWPKRS.21150705.7.vbs
    Code:
    ' Microsoft Windows Product Key Retrieval Script (MWPKRS)
    ' WinNT: v6+
    '             21150705.7 - 16:34 Alpha
    
    strMWPKRS = "MWPKRS: 21150705.7 - 16:34 Alpha"
    
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_CURRENT_USER  = &H80000001
    
    Dim objShell
    Dim arrPKey(4)
    
    Set colNamedArguments = WScript.Arguments.Named
    
    strComputer = "."
    strUsername = ""
    strPWD = ""
    
    oFolderPath = 000
    oFileName = "MSWPKRS-PKey.txt" 
    
    strComputer = colNamedArguments.Item("ip")
    strUsername = colNamedArguments.Item("usr")
    strPWD = colNamedArguments.Item("pwd")
    
    strOutput = colNamedArguments.Item("output")
    
            Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
            Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\default", strUsername, strPWD)
            Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUsername, strPWD)
            Set objShell = CreateObject("WScript.Shell")
    
            Set oReg = objSWbemServices.Get("StdRegProv")
            Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    qRegistry
    
    checkWinVer
    
    On Error Resume Next 
    
     WMI_Win32OS
     WMI_SLP
     WMI_SLS
     WMI_Win32CS
    
        Select Case oFolderPath
          Case 000 '* default
    oDirPath    = objShell.CurrentDirectory & "\"
          Case 101 '* SpecialFolders: Desktop
    oDirPath    = arrDesktopFolder(0) & "\"
          Case 201 '* SpecialFolders: AllUsersDesktop
    oDirPath    = arrDesktopFolder(1) & "\"
          Case 102 '* REG HKCU Desktop UserShellFolder
    oDirPath    = arrDesktopFolder(2) & "\"
          Case 103 '* REG HKCU Desktop ShellFolder
    oDirPath    = arrDesktopFolder(3) & "\"
          Case 202 '* REG HKLM CommonDesktop ShellFolder
    oDirPath    = arrDesktopFolder(4) & "\"
          Case Else
    oDirPath    = ".\"
          End Select
    
     If strOutput = "file" Then
          PKeyFile
     End If
    
         PKeyEcho
    
    Sub PKeyEcho
    
       WScript.Echo vbCR _
        & vbTAB & " Microsoft Windows Product Key Retrieval Script (MWPKRS) " & vbCR & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "  Microsoft Windows " & strLicCT & " Product Key" & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "   " & strSLPDesc & vbCR _
        & "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " & vbCR _
        & "Product Name: " & vbTAB & strOSCaption & vbCR _
        & "Edition ID: " & vbTAB & strRegEditionID & vbCR & vbCR _
        & "Product ID: " & vbTAB & strOSSerialNumber & vbCR _   
        & "Product Key: "  & vbTAB & chr(34) & strProductKey & chr(34) & vbCR _
        & "Partial Product Key: " & vbTAB & strSLPPartialPKey & vbCR & vbCR _
        & "Lic Type / Channel: " & vbTAB & "     " & strLicTypeChannel & vbCR _
        & "License Status: "  & vbTAB & "     " & strSLPLicenseStatus & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "Additional Product Key(s): " & vbCR & vbCR _
        & " HKLM.WinNT.CV.DigitalProductId:"   & vbTAB & strProductKey & vbCR _
        & " HKLM.WinNT.CV.DigitalProductId4:"  & vbTAB & strProductKey4 & vbCR & vbCR _
        & " WMI.SLP.PartialProductKey: " & vbTAB & vbTAB & strSLPPartialPKey & vbCR _
        & " WMI.SLS.OA3xOriginalProductKey:" & vbTAB & strSLSOA3xOriginalProductKey & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "--------------------------------------------------------------------------------------" & vbCR _
        & "WMI.CS.Manufacturer: " & vbTAB & strCSManufacturer & vbCR & vbCR _
        & "OEM Information:" & vbCR _
        & "   Manufacturer:" & vbTAB & vbTAB & strRegOEMInfoManufacturer & vbCR _
        & "   Model:" & vbTAB & vbTAB & vbTAB & strRegOEMInfoModel & vbCR _ 
        & "--------------------------------------------------------------------------------------" & vbCR _
        & Now  & vbTAB & vbTAB & vbTAB & strMWPKRS
    
        exportFilePKEY = MsgBox ("Save to file?" & vbCR & vbCR _ 
          & "File: " & oDirPath & oFileName, vbYesNo, "MWPKRS: Microsoft Windows Product Key > Save to file?")
    
    Select Case exportFilePKEY
    Case 6, vbYes
        PKeyFile
        WScript.Quit
    Case 7, vbNo
        WScript.Quit
      End Select
    
    End Sub
    
    
    Sub PKeyFile
    
    '// Output to File:
    
             Set outputTXT = objFSO.OpenTextFile(oDirPath & oFileName, 2, True)
    
       outputTXT.WriteLine ""
       outputTXT.WriteLine "                 Microsoft Windows Product Key Retrieval Script (MWPKRS)"
       outputTXT.WriteLine ""
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Microsoft Windows " & strLicCT & " Product Key"
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "    " & strSLPDesc
       outputTXT.WriteLine "    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
       outputTXT.WriteLine "     Product Name: " & vbTAB & vbTAB & strOSCaption
       outputTXT.WriteLine "     Edition ID: " & vbTAB & vbTAB & strRegEditionID
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Product ID: " & vbTAB & vbTAB & strOSSerialNumber
       outputTXT.WriteLine "     Product Key: " & vbTAB & vbTAB & chr(34) & " " & strProductKey & " " & chr(34)
       outputTXT.WriteLine "     Partial Product Key: " & vbTAB & strSLPPartialPKey
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     Lic Type / Channel: " & vbTAB & strLicTypeChannel
       outputTXT.WriteLine "     License Status: " & vbTAB  & vbTAB & strSLPLicenseStatus
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   Additional Product Key(s): "
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     REG.HKLM.WinNT.CV.DigitalProductId:"   & vbTAB & strProductKey
       outputTXT.WriteLine "     REG.HKLM.WinNT.CV.DigitalProductId4:"  & vbTAB & strProductKey4
       outputTXT.WriteLine ""
       outputTXT.WriteLine "     WMI.SLP.PartialProductKey: " & vbTAB & vbTAB & strSLPPartialPKey
       outputTXT.WriteLine "     WMI.SLS.OA3xOriginalProductKey:" & vbTAB & vbTAB & strSLSOA3xOriginalProductKey
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   WMI.CS.Manufacturer: " & vbTAB & strCSManufacturer
       outputTXT.WriteLine ""
       outputTXT.WriteLine "   OEM Information:"
       outputTXT.WriteLine "     Manufacturer:" & vbTAB & vbTAB & strRegOEMInfoManufacturer
       outputTXT.WriteLine "     Model:" & vbTAB & vbTAB & vbTAB & strRegOEMInfoModel 
       outputTXT.WriteLine "  --------------------------------------------------------------------------------------"
       outputTXT.WriteLine "   " & Now & vbTAB & vbTAB & vbTAB & vbTAB & strMWPKRS
       WScript.Quit
    End Sub
    
    
    Function checkWinVer
    
    'Check Windows Version :
    
     If Not strRegWinVersion => 6.0 Then
       WScript.Echo "WINDOWS VERSION ERROR:" & vbCR & vbCR _
        & " Microsoft Windows Product Key Retrieval Script (MWPKRS) " & vbCR _
        & "-----------------------------------------------------------------" & vbCR _
        & "  This script requires Windows Version 6.0 ( Vista ) and above!  " & vbCR _
        & "-----------------------------------------------------------------"
       WScript.Quit
     End If
    
    End Function
    
    
     Dim strRegWinVersion, strRegEditionID
     Dim strProductKey, strProductKey4
     Dim strRegOEMInfoManufacturer, strRegOEMInfoModel
     Dim arrDesktopFolder(4)
    
    Sub qRegistry
    
           keyNTCurrentVersion = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
           keyWinCurrVerOEMInfo = "SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation"
    
       ' Windows
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"CurrentVersion",strRegWinVersion
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"EditionID",strRegEditionID
    
       ' Product Key
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"DigitalProductId",pidBinary
            oReg.GetBinaryValue HKEY_LOCAL_MACHINE,keyNTCurrentVersion,"DigitalProductId4",pidBinary4
    
            strProductKey = fnDecipherMSKey(pidBinary)
            strPartialPK = Right("0" & strProductKey, 5)
    
            strProductKey4 = fnDecipherMSKey4(pidBinary4)
    
       ' OEM Information
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyWinCurrVerOEMInfo,"Manufacturer",strRegOEMInfoManufacturer
            oReg.GetStringValue HKEY_LOCAL_MACHINE,keyWinCurrVerOEMInfo,"Model",strRegOEMInfoModel
    
       ' Shell Folders
             keyHKCRUserShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
              oReg.GetStringValue HKEY_CURRENT_USER,keyHKCRUserShellFolders,"Desktop",strCUserDesktop
             keyHKCRShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
               oReg.GetStringValue HKEY_CURRENT_USER,keyHKCRShellFolders,"Desktop",strCUserDesktopSF
             keyHKLMShellFolders = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
              oReg.GetStringValue HKEY_LOCAL_MACHINE,keyHKLMShellFolders,"Common Desktop",strCommonDesktopSF
    
             arrDesktopFolder = Array(objShell.SpecialFolders("Desktop"), _
                                      objShell.SpecialFolders("AllUsersDesktop"), _
                                      strCUserDesktop, strCUserDesktopSF, strCommonDesktopSF)
    End Sub
    
    
    Dim strOSCaption, strOSSerialNumber, strOSType
    
    Sub WMI_Win32OS
    
    ' Win32_OperatingSystem:
        Set colOS  = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
    
      For Each objOS in colOS 
    
    ' Set variables gathered from Win32_OperatingSystem class:
    
            strOSCaption = objOS.Caption
            strOSSerialNumber = objOS.SerialNumber
    '        strOSSerialNumberX = Replace(objOS.SerialNumber,"-","XXXXX-",6,1)
            strOSType = objOS.OSType
    Next 
    End Sub
    
    
    Dim strSLPDesc, strSLPPartialPKey
    Dim strLicTypeChannel, strLicCT, strSLPLicenseStatus
    
    Sub WMI_SLP
    
    ' SoftwareLicensingProduct:
        Set colSLP = objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingProduct WHERE NOT PartialProductKey = null AND Description > 'Operating System'",,48) 
    
      For Each objSLP in colSLP 
    
    ' Set variables gathered from SoftwareLicensingProduct:
    
            strSLPDesc = objSLP.Description
            strSLPPartialPKey = objSLP.PartialProductKey
    
    ' Get License Type / Channel from objSLP.Description:
    
    
           If InStrB(strSLPDesc,"OEM_SLP") <> 0 then 
               strLicTypeChannel = "2 - OEM SLP / OEM_SLP"
               strLicCT = "OEM_SLP"
           ElseIf InStrB(strSLPDesc,"OEM_COA_SLP") <> 0 then 
               strLicTypeChannel = "8 - COA SLP / OEM_COA_SLP"
               strLicCT = "OEM_COA_SLP"
           ElseIf InStrB(strSLPDesc,"OEM_DM") <> 0 then 
               strLicTypeChannel = "    OEM Digital Marker / OEM_DM"
               strLicCT = "OEM_DM"
           ElseIf InStrB(strSLPDesc,"OEM_COA_NSLP") <> 0 then 
               strLicTypeChannel = "3 - OEM System Builder / OEM_COA_NSLP"
               strLicCT = "OEM_COA_NSLP"
           ElseIf InStrB(strSLPDesc,"RETAIL") <> 0 then 
               strLicTypeChannel = "5 - Retail / RETAIL"
               strLicCT = "RETAIL"
           ElseIf InStrB(strSLPDesc,"VOLUME_MAK") <> 0 then 
               strLicTypeChannel = "6 - Volume MAK / VOLUME_MAK"
               strLicCT = "VOLUME_MAK"
           ElseIf InStrB(strDesc,"VOLUME_KMSCLIENT") <> 0 then 
               strLicTypeChannel = "1 - KMS Client / VOLUME_KMSCLIENT"
               strLicCT = "VOLUME_KMSCLIENT"
           ElseIf InStrB(strDesc,"VOLUME_KMS") <> 0 then 
               strLicTypeChannel = "7 - Volume KMS Server / VOLUME_KMS"
               strLicCT = "VOLUME_KMS"
           Else strLicTypeChannel = "Unknown"
               strLicCT = "Unknown"
          End If
    
    ' Get License Status from SoftwareLicensingProduct:
    
     Const HR_S_OK                                 = 0
    Const HR_ERROR_FILE_NOT_FOUND                 = &H80070002
    Const HR_SL_E_GRACE_TIME_EXPIRED              = &HC004F009
    Const HR_SL_E_NOT_GENUINE                     = &HC004F200
    
      Select Case objSLP.LicenseStatus
           Case "0" strSLPLicenseStatus = "Unlicensed"
           Case "1" strSLPLicenseStatus = "Licensed"
           Case "2" strSLPLicenseStatus = "Out-Of-Box Grace Period"
           Case "3" strSLPLicenseStatus = "Out-Of-Tolerance Grace Period"
           Case "4" strSLPLicenseStatus = "Non-Genuine Grace Period"
           Case "5" strSLPLicenseStatus = "Notification"
     Select Case objSLP.LicenseStatusReason
     Case HR_SL_E_GRACE_TIME_EXPIRED : strSLPLicenseStatus = strSLPLicenseStatus & ", grace time expired [code &HC004F009]"
     Case HR_SL_E_NOT_GENUINE : strSLPLicenseStatus = strSLPLicenseStatus & ", not genuine [code &HC004F200]"
     Case Else : strSLPLicenseStatus = strSLPLicenseStatus + " [code " & objSLP.LicenseStatusReason & "]"
     End Select
           Case "6" strSLPLicenseStatus = "Extended Grace"
        Case Else
    strSLPLicenseStatus = objSLP.LicenseStatus
      End Select
    
    Next
    End Sub
    
    
    Dim strSLSOA3xOriginalProductKey
    
    Sub WMI_SLS
    
    ' SoftwareLicensingService:
        Set colSLS = objWMIService.ExecQuery("SELECT * FROM SoftwareLicensingService",,48) 
    
      For Each objSLS in colSLS 
    
    ' Set variables gathered from SoftwareLicensingService:
    
            strSLSOA3xOriginalProductKey = objSLS.OA3xOriginalProductKey
    
    Next
    End Sub
    
    
    Dim strCSManufacturer
    
    Sub WMI_Win32CS
    
    ' Win32_ComputerSystem:
        Set colCS  = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48)
    
      For Each objCS in colCS 
    
    ' Set variables gathered from SoftwareLicensingProduct:
    
            strCSManufacturer = objCS.Manufacturer
    Next
    End Sub
    
    Private Function fnDecipherMSKey(BinaryValuePID)
        Const KeyOffset = 52
        isWin8 = (BinaryValuePID(66) \ 6) And 1
        BinaryValuePID(66) = (BinaryValuePID(66) And &HF7) Or ((isWin8 And 2) * 4)
        i = 24
        Chars = "BCDFGHJKMPQRTVWXY2346789"
        Do
            Cur = 0
            X = 14
            Do
                Cur = Cur * 256
                Cur = BinaryValuePID(X + KeyOffset) + Cur
                BinaryValuePID(X + KeyOffset) = (Cur \ 24)
                Cur = Cur Mod 24
                X = X -1
            Loop While X >= 0
            i = i -1
            KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
            Last = Cur
        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
    
         arrPKey(0) = Mid(KeyOutput, 1, 5)
         arrPKey(1) = Mid(KeyOutput, 6, 5)
         arrPKey(2) = Mid(KeyOutput, 11, 5)
         arrPKey(3) = Mid(KeyOutput, 16, 5)
         arrPKey(4) = Mid(KeyOutput, 21, 5)
    
         fnDecipherMSKey = Join(arrPKey,"-")
    End Function
    
    Private Function fnDecipherMSKey4(BinaryValuePID)
        Const KeyOffset = 808
        isWin8 = (BinaryValuePID(66) \ 6) And 1
        BinaryValuePID(66) = (BinaryValuePID(66) And &HF7) Or ((isWin8 And 2) * 4)
        i = 24
        Chars = "BCDFGHJKMPQRTVWXY2346789"
        Do
            Cur = 0
            X = 14
            Do
                Cur = Cur * 256
                Cur = BinaryValuePID(X + KeyOffset) + Cur
                BinaryValuePID(X + KeyOffset) = (Cur \ 24)
                Cur = Cur Mod 24
                X = X -1
            Loop While X >= 0
            i = i -1
            KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
            Last = Cur
        Loop While i >= 0
        If (isWin8 = True) 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
    
         arrPKey(0) = Mid(KeyOutput, 1, 5)
         arrPKey(1) = Mid(KeyOutput, 6, 5)
         arrPKey(2) = Mid(KeyOutput, 11, 5)
         arrPKey(3) = Mid(KeyOutput, 16, 5)
         arrPKey(4) = Mid(KeyOutput, 21, 5)
    
         fnDecipherMSKey4 = Join(arrPKey,"-")
    End Function
    
     
  18. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
  19. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,858
    2,115
    60
    #19 Muerto, Jul 2, 2015
    Last edited: Jan 15, 2021
    ...
     
  20. 38956

    38956 MDL Member

    Jun 7, 2010
    130
    138
    10
    #20 38956, Jul 4, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)

    Thanks for the feedback.


    Can you try this
    Code:
    SELECT * FROM SoftwareLicensingProduct WHERE NOT PartialProductKey = null AND Description > 'Operating System'
    Thanks