Skip to main content
Kofax

Scripting - How to get Kofax license information and serial number by script or API

Article # 3032305 - Page views: 261

UndefinedNameError: reference to undefined name 'undefined' (click for details)
Callstack:
    at (Capture/Kofax_Capture/How_To/Scripting_-_How_to_get_Kofax_license_information_and_serial_number_by_script_or_API), /content/body/div/pre, line 2, column 1
 
 

Issue

What API can be used to get Kofax license information and serial number by script?

Solution

You need to add a reference to the file KSALicClnt.dll in Kofax Capture Bin folder in your project.

Afterwards you can use the following VB.NET code to get several information:

  Dim cc As New Kofax.SAL.Client.SALicClientConnection
  addinfo("Server Date", cc.GetServerDate().ToString)
  addinfo("Kofax Serial Number", cc.GetDisplayProductSerialNumber())
  addinfo("Server ", cc.Server.Name + ":" + cc.Server.PortNumber.ToString)
  Dim machineIDs() = cc.GetMachineIDs()
  For Each id As String In machineIDs
    addinfo("Machine ID", id)
  Next

Please note that addinfo is declared as Public Sub addinfo(name As String, value As String) to add the entries to a listview, as you see in detailed example below.

Minimum Kofax Capture Version is KC 8.0.

Detailed volume information are available, too. The result could look like this:

screenshot_licenseinfo.jpg

Code example:

Public License_server_connection_failed as Integer = 0  ' monitor externally, if connection failed too often
 
Public Sub refresh_values()
        ListViewSystem.Items.Clear()
        ListViewFeatures.Items.Clear()
        ListViewVolume.Items.Clear()
        ListViewMixed.Items.Clear()
        ListViewClients.Items.Clear()
 
        Dim cc As New Kofax.SAL.Client.SALicClientConnection
 
        If Not cc.IsConnected Then
            cc = Nothing
            License_server_connection_failed = License_server_connection_failed + 1
            Exit Sub
        End If
        License_server_connection_failed = 0 ' reset value
 
 
        Dim machineIDs() = cc.GetMachineIDs()
        For Each id As String In machineIDs
            addinfo("Machine ID", id)
        Next
        '      addinfo("Kofax Serial Number", cc.GetDisplayProductSerialNumber())
        '      addinfo("Server ", cc.Server.Name + ":" + cc.Server.PortNumber.ToString)
        addinfo("Last Volume Activation", cc.GetLastVolumeActivation().ToString)
        addinfo("Server Date", cc.GetServerDate().ToString)
        addinfo("License Version", cc.GetVersion().ToString)
 
        ToolStripStatusLabelSerialNumber.Text = "Kofax Serial Number: " + cc.GetDisplayProductSerialNumber()
        ToolStripStatusLabelServer.Text = "Server: " + cc.Server.Name + ":" + cc.Server.PortNumber.ToString
        
        Dim hosts() = cc.GetHosts()
        For Each hostinfo As String In hosts
            Dim host As String = hostinfo
            Dim session As String = ""
            session = ""
            If hostinfo.IndexOf(":") > 0 Then
                host = host.Substring(0, hostinfo.IndexOf(":"))
                hostinfo = hostinfo.Substring(hostinfo.IndexOf(":") + 1)
            End If
            If hostinfo.IndexOf(":") > 0 Then
                session = hostinfo.Substring(0, hostinfo.IndexOf(":"))
            End If
            ListViewClients.Items.Add(host).SubItems.Add(session)
        Next
 
        Dim limitBelow As Boolean = False
        Dim li As ListViewItem
        Dim limit As Integer
 
        For i As Integer = 0 To cc.GetLicenseCount - 1
            Dim lic As Kofax.SAL.Client.SALicClientInfo = cc.GetLicenseInfoFromIndex(i)
 
            If lic.IsSystemLicense Then
                li = ListViewSystem.Items.Add(lic.Name)
                If lic.Expires > Now.AddYears(-100) Then
                    li.SubItems.Add(lic.Expires)
                Else
                    li.SubItems.Add("(none)")
                End If
                li.SubItems.Add(lic.ID)
            ElseIf lic.IsFeatureLicense Then
                li = ListViewFeatures.Items.Add(lic.Name)
                li.Tag = lic.ID
                li.SubItems.Add(lic.FeatureCountCurrent.ToString)
                li.SubItems.Add((lic.FeatureCountMax - lic.FeatureCountCurrent).ToString)
                li.SubItems.Add(lic.FeatureCountMax.ToString)
                If lic.Expires > Now.AddYears(-100) Then
                    li.SubItems.Add(lic.Expires)
                Else
                    li.SubItems.Add("(none)")
                End If
                li.SubItems.Add(lic.ID)
            Else
                If lic.AbsoluteVolumeMax > 0 Then
                    li = ListViewVolume.Items.Add(lic.Name + " - one time")
                    li.Tag = lic.ID
                    li.SubItems.Add((lic.AbsoluteVolumeMax - lic.AbsoluteVolumeCurrent).ToString)
                    li.SubItems.Add(lic.AbsoluteVolumeMax.ToString)
 
 
                    If lic.Expires > Now.AddYears(-100) Then
                        li.SubItems.Add(lic.Expires)
                    Else
                        li.SubItems.Add("(none)")
                    End If
                    If lic.PeriodStart > Now.AddYears(-100) Then
                        li.SubItems.Add(lic.PeriodStart)
                    Else
                        li.SubItems.Add("(none)")
                    End If
                    li.SubItems.Add(lic.ID)
                    limit = getLimit(lic.ID)
                    li.SubItems.Add(BoolSt(limit <= 0, "-", limit.ToString))
                    'If (limit > 0) AndAlso (lic.AbsoluteVolumeMax - lic.AbsoluteVolumeCurrent < limit) Then
                    '    limitBelow = True
                    'End If
 
                End If
 
                If lic.PeriodicVolumeMax > 0 Then
                    Dim s As String
                    Select Case lic.PeriodicVolumeTime
                        Case Kofax.SAL.Client.SALicClientInfo.LicensePeriods.Yearly : s = "annual"
                        Case Kofax.SAL.Client.SALicClientInfo.LicensePeriods.Monthly : s = "monthly"
                        Case Kofax.SAL.Client.SALicClientInfo.LicensePeriods.None : s = "none"
                    End Select
                    li = ListViewVolume.Items.Add(lic.Name + " - " + s)
                    li.Tag = lic.ID
                    li.SubItems.Add((lic.PeriodicVolumeMax - lic.PeriodicVolumeCurrent).ToString)
                    li.SubItems.Add(lic.PeriodicVolumeMax.ToString)
                    If lic.Expires > Now.AddYears(-100) Then
                        li.SubItems.Add(lic.Expires)
                    Else
                        li.SubItems.Add("(none)")
                    End If
                    If lic.PeriodStart > Now.AddYears(-100) Then
                        li.SubItems.Add(lic.PeriodStart)
                    Else
                        li.SubItems.Add("(none)")
                    End If
                    li.SubItems.Add(lic.ID)
 
                    ' limit = getLimit(lic.ID)
                    ' li.SubItems.Add(BoolSt(limit <= 0, "-", limit.ToString))
                    ' If (limit > 0) AndAlso (lic.PeriodicVolumeMax - lic.PeriodicVolumeCurrent < limit) Then
                    '    limitBelow = True
                    ' End If
                End If 
            End If
        Next
 
        'If limitBelow Then
        '    If Now > LastTimeExecution.AddMinutes(WaitTimeMinutes) Then
        '       LastTimeExecution = Now
        '       doExecute(executeLines)
        '    End If
        'End If
 
        cc = Nothing
End Sub
 
Public Sub addinfo(name As String, value As String)
   Dim li As ListViewItem = ListViewMixed.Items.Add(name)
   li.subitems.add(value)
End Sub


If you would like to monitor your licenses or remaining page count volumes then you can set a limit (or a limit for each type) and send a notification to you.

Level of Complexity 

Moderate

 

Applies to  

Product Version Build Environment Hardware
Kofax Capture

10.2,
11.0, 11.1

     

References

Add any references to other internal or external articles

  • Was this article helpful?