SLPS Developer Discussion Developer level questions on Code Protection, Licensing, customisation APIs etc
InishTech Support Forums > SLPS Developer Discussion > Silent license activation Login to add this as a favourite.
User avatar
Member
Member
alexandrv - 10/5/2017 11:44:25 AM
   
Silent license activation

Hello!

Is there a way to activate license silently without any user interaction?

We need to support silent installation mode for the product, license activation is a part of installation. Now we run the activation wizard programmatically using the following code:

 

using (SLMRuntime slm = OpenSLMRuntimeSession())
{
    using (IActivationWizard dlg = CreateActivationDialog(slm))
    {
        dlg.ShowDialog(null);
        result = (dlg.InstalledLicense != null);
    }
 
    slm.CloseSession();
}

Is it possible to avoid showing this dialog to user and specify either license key or license file to activate license silently? Thanks.


User avatar
Member
Member
ServiceAdmin - 10/19/2017 11:56:26 AM
   
RE:Silent license activation

 Hi Alex,

It is possible to activate a license programmatically via the SP (Microsoft.Licensing) runtime as per the snippet below:

  • Create an activation client for the Product and Version
  • Call the Activate method with the activation key
            string permShortcode = "123ab"; //TODO: substitute in you vendor's own permutation short code.
            using (var _slmRuntime = new SLMRuntime(permShortcode))
            {
               try
               {
                   // Create an activation client for the product name and version
                   IActivationClient activationClient = _slmRuntime.Activation.CreateActivationClient("YourProduct", "Version");

                   // Call the activation client to renew the license with the retrieved license key
                   activationClient.Activate(licenseKey, "");

               }
               catch (ActivationServerException ex)
               {
                   // Log the exception 
                   throw ex;
               }
               catch (ActivationClientException cex)
               {
                  throw cex;
               }
          }

Hope this helps.

Please note this site will be shutdown at the end of Dec 2017 as it has been replaced by our new support site at http://support.softwarepotential.com.    We strongly recommend you direct all future support queries to the new site or send the query by email to support@softwarepotential.com.
 


1

There are currently no users on-line.

  • Sticky
  • Locked sticky
  • Hot sticky
  • Hot locked sticky
  • Thread
  • Hot thread
  • Locked thread