Keyman Desktop includes a comprehensive API that allows you to control nearly every aspect of its behaviour.  Today I’d like to focus on one small method of automating Keyman Desktop, that is, activating Keyman Desktop via script.

The activation process requires three steps:

  1. Pass the license key in to Keyman Engine and get activation request binary data in response
  2. Send this activation request binary data to the Tavultesoft activation server and receive activation response binary data in response
  3. Pass the activation response binary data to Keyman Engine to complete activation

This can be done neatly with Windows Script Host.  This script could be used in a number of scenarios, including Windows Installer or Active Directory scripts.  Error management is left up to the Keyman Engine and XMLHTTPRequest objects, and any errors will abort the script.

This script does not check if Keyman Desktop is already activated.  That can easily be added using the GetProductActivationInfo function in ITavultesoftKeymanScript; there is no harm in reactivating but obviously you can save a call to the Tavultesoft activation server if you don’t need to reactivate.

The script must run in x86 context, so on Windows x64 hosts, make sure you use the cscript.exe or wscript.exe script host from the SYSWOW64 folder.

If you run the script with elevated privileges, then the activation will apply for all users; otherwise the activation will only apply for the current user.

  ‘ =======================================================================

  ‘ ActivationScript.vbs.
  ‘ (C) 2012 Tavultesoft Pty Ltd
  ‘ Author:  Marc Durdin
  ‘ Version: 1.0
  ‘ Date:    27 Feb 2012
  ‘ For support with this script, please contact
  ‘ Tavultesoft Support <>
  ‘ This script activates the product specified below with the license
  ‘ details embedded
in this script.

  ‘ The script must run in x86 context, not x64 context.
  ‘ The script can be embedded in an .msi file, for example w
ith a
  ‘ WiX custom action, wrap the code in a function called Activate()
  ‘ and add the following fragment to your .wxs source file:

  ‘  <Binary Id=”ActivationScript.vbs” SourceFile=”ActivationScript.vbs” />
  ‘  <CustomAction BinaryKey=”ActivationScript.vbs” Execute=”deferred”
  ‘   Id=”Activation” HideTarget=”yes”

  ‘   Impersonate=”no” Return=”check”
  ‘   VBScriptCall=”Activate” Win64=”no” />

  ‘  <InstallExecuteSequence>
  ‘    <Custom Action=”Activation” Before=”InstallFinalize” />
  ‘  </InstallExecuteSequence>
  ‘ =======================================================================

  dim LicenseNumber, ProductID

  ‘ ================================
  ‘ Start of user-definable settings
  ‘ ================================

  ‘ LicenseNumber – the license number you have been provided with by Tavultesoft

  LicenseNumber = “1234-5678-ABCD-EFGH-IJKL”  ‘ This is not a valid license number!

  ‘ ProductID:
  ‘   Keyman Desktop Pro 8.0 = 12
  ‘   Keyman Desktop Light 8.0 = 13
  ‘   Keyman Developer 8.0 = 14
  ‘   Other product IDs can be found in the registry when the product is installed,
  ‘   in HKEY_LOCAL_MACHINESoftwareTavultesoftKeyman Engine8.0
  ‘       Installed Products[productname]product id


  ProductID = 12  

  ‘ ==============================
  ‘ End of user-definable settings
  ‘ ==============================

  dim kmcom, kmcom2
  dim ActivationRequest, ActivationResponse, XMLHttpRequest, ActivationURL

  ‘ ========================================================================
  ‘ Create Tavultesoft Keyman objects.  We need both because we are using
  ‘ VBScript which
cannot access some of the activation functions in the
  ‘ IKeymanProduct interface and so
must use the ITavultesoftKeymanScript
  ‘ alternatives

  ‘ ========================================================================

  Set kmcom = CreateObject(“kmcomapi.TavultesoftKeyman”)
  Set kmcom2 = CreateObject(“kmcomapi.TavultesoftKeymanScript”)

  ‘ ========================================================================
  ‘ Generate an activation request blob
  ‘ ========================================================================

  ActivationRequest = kmcom2.GetProductActivationRequest(ProductID, LicenseNumber)

  ‘ ========================================================================
  ‘ Send the activation request blob to the Tavultesoft secure server for activation
  ‘ For proxy, see:
  ‘ ========================================================================

  ActivationURL = “”
  Set XMLHTTPRequest = CreateObject(“MSXML2.ServerXMLHTTP.6.0”) “POST”, ActivationURL, FALSE
  XMLHTTPRequest.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”
  XMLHTTPRequest.send “ActivationRequestBlob=”+ActivationRequest

  ‘ ========================================================================
  ‘ Collect the activation response blob from the response and pass it into the
  ‘ kmcom IKeymanProduct.Activate function to complete the activation.  Activation will
  ‘ be per-user for a local user security context, or per-machine for an elevated
  ‘ security context.
  ‘ ========================================================================

  ActivationResponse = XMLHTTPRequest.responseText

  ‘ EOF

ActivatedState = km.GetProductActivationInfo(ProductID, 1)
IF ActivatedState = 0
Categories: Using Keyman Desktop

0 thoughts on “Activating Keyman Desktop with Windows Script”

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Developing Keyman

Keyman is now free and open source

SIL International is very pleased to announce that Keyman is now completely free and open source! Today, 23 August 2017, we released free versions of the existing Keyman products on the Keyman website, and have Read more…

Using Keyman Desktop

Activation of Keyman Desktop for Network Administrators

This is a quick technical note on different ways to activate Keyman Desktop for system administrators. Activation using a command line tool The simplest way is using the command line for kmshell.exe (located in Program Files Read more…

Using Keyman Desktop

Working through Malayalam display in Windows

Some Keyman users have recently brought to our attention inconsistencies in the appearance of Malayalam text when viewed with different fonts.  Although this has become more apparent with the release of new versions of  Keyman Read more…