Client Management Suite

 View Only
  • 1.  Capturing software serial numbers

    Posted Apr 04, 2011 01:48 PM

    I am trying to capture any known serial numbers that are saved on a laptop.  I am mostly interested in gathering Microsoft and Adobe keys to verify that the software installed on the machines was actually installed by us and users are not using personal software.  I have searched on here and few other sites and have seen a few ideas but none seem to be working for me.  If anyone knows of a way to do this and could help out or at least point me in the right direction, I would appreciate it. 



  • 2.  RE: Capturing software serial numbers

    Posted Apr 04, 2011 02:02 PM

    Belarc Advisor or Magical Jelly Bean Keyfinder.  Altiris does not include this functionality.



  • 3.  RE: Capturing software serial numbers

    Posted Apr 04, 2011 03:23 PM

    I found this script somewhere on this site last week.  It creates an .nsi file on the local machine.  This one captures all Microsoft OS and Office keys.  I believe this was written for an older version of the CMS but I have it to where it creates the file.  I now need to know how to get it to include in the inventory (which I don't think is actually possible) or I need to know if I need to create a new task/job to collect that file and put it in the DB.  Here is the script and below it are the results:

    On Error Resume Next
    Const HKEY_LOCAL_MACHINE = &H80000002
    Dim StdRegProv
    Set StdRegProv = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    Dim CustInvClassName
    CustInvClassName = "Inv AeX SW OS and Office ProductKeys"
    Dim CutInvNSI
    Dim ProductName
    Dim ProductKey
    Dim KeyList(3)
    KeyList(0) = "SOFTWARE\MICROSOFT\Windows NT\CurrentVersion" ' OS
    KeyList(1) = "SOFTWARE\MICROSOFT\Office\11.0\Registration" ' Office 2003
    KeyList(2) = "SOFTWARE\MICROSOFT\Office\10.0\Registration" ' Office XP
    KeyList(3) = "SOFTWARE\MICROSOFT\Office\12.0\Registration" ' Office 2007
    KeyList(4) = "SOFTWARE\MICROSOFT\Office\13.0\Registration" ' Office 2010
    CutInvNSI = NSIHeadText(CustInvClassName)
    ProductKey = GetOSProductKey(KeyList(0))
    KeyData = Split(ProductKey, ";", -1, 1)
    If UBound(KeyData) > -1 Then
        CutInvNSI = CutInvNSI & "        <z:row" & " c0=""" & KeyData(0) & """" & " c1=""" & KeyData(1) & """" & "/>" & vbCrLf
    End If    
    For ZLoop = 1 To 3
        ProductKeys = SearchProductKeys(KeyList(ZLoop))
        FoundKeys = Split(ProductKeys, "|", -1, 1)
        If UBound(FoundKeys) > -1 Then
            For YLoop = 0 To UBound(FoundKeys)
                KeyData = Split(FoundKeys(YLoop), ";", -1, 1)
                CutInvNSI = CutInvNSI & "        <z:row" & " c0=""" & KeyData(0) & """" & " c1=""" & KeyData(1) & """" & "/>" & vbCrLf
            Next
        Else
            KeyData = Split(ProductKeys, ";", -1, 1)
            If UBound(KeyData) > -1 Then
                CutInvNSI = CutInvNSI & "        <z:row" & " c0=""" & KeyData(0) & """" & " c1=""" & KeyData(1) & """" & "/>" & vbCrLf
            End If    
        End If
    Next
    CutInvNSI = CutInvNSI & NSIFootText
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile("C:\Program Files\Altiris\" & Replace(CustInvClassName, " ", "_") & ".nsi", 2, True)
    objTextFile.WriteLine(CutInvNSI)
    objTextFile.close
    Function NSIHeadText(NSIClassName)
        Dim TempReturn
        TempReturn = "<InventoryClasses>" & vbCrLf
        TempReturn = TempReturn & "  <InventoryClass name='" + NSIClassName + "' manufacturer='Altiris' description='' version='' platform='Win32' mifClass='Altiris|" + Replace(NSIClassName, " ", "_") + "|1.0'>" & vbCrLf
        TempReturn = TempReturn & "    <xml xmlns:s=""uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"" xmlns:dt=""uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"" xmlns:rs=""urn:schemas-microsoft-com:rowset"" xmlns:z=""#RowsetSchema"">" & vbCrLf
        TempReturn = TempReturn & "      <s:Schema id=""RowsetSchema"">" & vbCrLf
        TempReturn = TempReturn & "        <s:ElementType name=""row"" content=""eltOnly"" rs:updatable=""true"">" & vbCrLf
        TempReturn = TempReturn & "          <s:AttributeType name=""c0"" rs:name=""Product Name"" rs:number=""1"" rs:keycolumn=""true"" mifAttrId='1'>" & vbCrLf
        TempReturn = TempReturn & "            <s:datatype dt:type=""string"" dt:maxLength=""255""/>" & vbCrLf
        TempReturn = TempReturn & "          </s:AttributeType>" & vbCrLf
        TempReturn = TempReturn & "          <s:AttributeType name=""c1"" rs:name=""Product Key"" rs:number=""2"" rs:keycolumn=""true"" mifAttrId='2'>" & vbCrLf
        TempReturn = TempReturn & "            <s:datatype dt:type=""string"" dt:maxLength=""255""/>" & vbCrLf
        TempReturn = TempReturn & "          </s:AttributeType>" & vbCrLf
        TempReturn = TempReturn & "        </s:ElementType>" & vbCrLf
        TempReturn = TempReturn & "      </s:Schema>" & vbCrLf
        TempReturn = TempReturn & "      <rs:data>" & vbCrLf
        NSIHeadText = TempReturn
    End Function
    Function NSIFootText
        Dim TempReturn
        TempReturn = "      </rs:data>" & vbCrLf
        TempReturn = TempReturn & "    </xml>" & vbCrLf
        TempReturn = TempReturn & "  </InventoryClass>" & vbCrLf
        TempReturn = TempReturn & "</InventoryClasses>" & vbCrLf
        NSIFootText = TempReturn
    End Function
    Function GetOSProductKey(StartKeyPath)
        GetOSProductKey = GetProductName(StartKeyPath) & ";" & GetProductKey(StartKeyPath)
    End Function
    Function SearchProductKeys(StartKeyPath)
        On Error Resume Next
        StdRegProv.EnumKey HKEY_LOCAL_MACHINE, StartKeyPath, ArraySubKeys
        For Each Subkey In ArraySubKeys
            If Err.Number <> 0 Then
                Err.Clear
                Exit Function
            End if
            StdRegProv.EnumValues HKEY_LOCAL_MACHINE, StartKeyPath & "\" & Subkey, ArrayNames, ArrayTypes
            TempProductName = ""
            TempProductKey = ""
            For ZLoop = 0  To UBound(ArrayNames)
                If Err.Number <> 0 Then
                    Err.Clear
                    Exit Function
                End If
                If LCase(ArrayNames(ZLoop)) =  "productname" Then
                    TempProductName = GetProductName(StartKeyPath & "\" & SubKey)
                End If
                If LCase(ArrayNames(ZLoop)) =  "digitalproductid" Then
                    TempProductKey = GetProductKey(StartKeyPath & "\" & SubKey)
                End If
            Next
            If TempProductName <> "" And TempProductKey <> "" Then
                If TempReturn <> "" Then
                    TempReturn = TempReturn & "|" & TempProductName & ";" & TempProductKey
                Else
                    TempReturn = TempProductName & ";" & TempProductKey
                End If
            End If
        Next
        SearchProductKeys = TempReturn
    End Function
    Function GetProductName(NameKeyPath)
        StdRegProv.GetStringValue HKEY_LOCAL_MACHINE, NameKeyPath, "ProductName", TempReturn
        GetProductName = TempReturn
    End Function
    Function GetProductKey(DigitalKeyPath)
        On Error Resume Next    
        Dim KeyDigit(23)
        KeyDigit(0) = "B"
        KeyDigit(1) = "C"
        KeyDigit(2) = "D"
        KeyDigit(3) = "F"
        KeyDigit(4) = "G"
        KeyDigit(5) = "H"
        KeyDigit(6) = "J"
        KeyDigit(7) = "K"
        KeyDigit(8) = "M"
        KeyDigit(9) = "P"
        KeyDigit(10) = "Q"
        KeyDigit(11) = "R"
        KeyDigit(12) = "T"
        KeyDigit(13) = "V"
        KeyDigit(14) = "W"
        KeyDigit(15) = "X"
        KeyDigit(16) = "Y"
        KeyDigit(17) = "2"
        KeyDigit(18) = "3"
        KeyDigit(19) = "4"
        KeyDigit(20) = "6"
        KeyDigit(21) = "7"
        KeyDigit(22) = "8"
        KeyDigit(23) = "9"
        StdRegProv.GetBinaryValue HKEY_LOCAL_MACHINE, DigitalKeyPath, "DigitalProductId", TempArray
        If Err.Number <> 0 Then
            Err.Clear
            Exit Function
        End if
        For YLoop = 24 To 0 Step -1
            CurDigit = 0
            For XLoop = 14 To 0 Step -1
                CurDigit = CurDigit * 256 Xor TempArray(XLoop + 52)
                Temparray(XLoop + 52) = Int(CurDigit / 24)
                CurDigit = CurDigit Mod 24
            Next
            TempReturn = KeyDigit(CurDigit) & TempReturn
            If YLoop Mod 5 = 0 And YLoop <> 0 Then
                TempReturn = "-" & TempReturn
            End If
        Next
        GetProductKey = TempReturn
    End Function

     

    RESULTS (minus the actual keys)

    <InventoryClasses>
      <InventoryClass name='Inv AeX SW OS and Office ProductKeys' manufacturer='Altiris' description='' version='' platform='Win32' mifClass='Altiris|Inv_AeX_SW_OS_and_Office_ProductKeys|1.0'>
        <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
          <s:Schema id="RowsetSchema">
            <s:ElementType name="row" content="eltOnly" rs:updatable="true">
              <s:AttributeType name="c0" rs:name="Product Name" rs:number="1" rs:keycolumn="true" mifAttrId='1'>
                <s:datatype dt:type="string" dt:maxLength="255"/>
              </s:AttributeType>
              <s:AttributeType name="c1" rs:name="Product Key" rs:number="2" rs:keycolumn="true" mifAttrId='2'>
                <s:datatype dt:type="string" dt:maxLength="255"/>
              </s:AttributeType>
            </s:ElementType>
          </s:Schema>
          <rs:data>
            <z:row c0="Microsoft Windows XP" c1="XXXXX-XXXXX-XXXXX-XXXXX-XXXXXX"/>
            <z:row c0="Microsoft Office Professional Edition 2003" c1="XXXXX-XXXXX-XXXXX-XXXXX-XXXXXX"/>
            <z:row c0="Microsoft Office Project Professional 2003" c1="XXXXX-XXXXX-XXXXX-XXXXX-XXXXXX"/>
            <z:row c0="Microsoft Office Visio Standard 2003" c1="XXXXX-XXXXX-XXXXX-XXXXX-XXXXXX"/>
          </rs:data>
        </xml>
      </InventoryClass>
    </InventoryClasses>