CHARON on Windows - Automated License Expiration Check

CHARON on Windows - Automated License Expiration Check

Version: 1.18 - PublishedJan 17, 2023 

Table of contents

Description

The goal of this Powershell script is to read the license content and send alerts 15 days (by default) before expiration. This document is related to the kit versions 1.9 to 1.17.

This utility is replaced by CHARON on Windows - Charon License Utility that provides a graphical interface providing the Windows server has PowerShell 5.1 and .NET Framework 4.6 minimum installed (4.8 recommended) installed.

Alerts consist in:

  • Adding a Windows Event entry in the Application log

  • Executing a customized script named "expiredlicense.bat" that can execute actions at your convenience: send an email, send an event to a monitoring software, etc...

Alert levels:

Days before expiration (date limited license)

Hours before expiration (time limited license)

Alert level

Between 7 and number of days defined (15 by default)

Between 73 and 96 hours

Informational

Between 3 and 7

Between 49 and 72 hours

Warning

Less than 3 and expired

Less than 49 and expired

Error

Related products:

Charon-AXP and Charon-VAX/PDP V4.5 and above

Operating systems:

Windows 7, Windows 8.1, Windows 10 Professional, Windows Server 2008 R2, Windows Server 2012 (R2), Windows Server 2016, Windows Server 2019

Step-by-step guide

Installation

  • Create a folder dedicated to store the scripts, for example: "C:\Charon"

  • Download the kit from our SFTP server (please ask us connection credentials if you have no access) and extract all files in this folder.
    The kit contains some files, their usage is described further in this document.
    .

  • Optionally create the "expiredlicense.bat" file in the same folder and customize it at your own (to send emails for example).

    If the script does not exist, a warning event will be posted but it will not prevent the script from running. In this case only Windows Application events will be sent.

    .
    Below is a simple example to append entries in a log file. You will find further in this article an example on how to send an email using powershell.

    echo %date% %time% %1 %2 >> C:\Charon\expiredlicense.log

    Notes:

    • "%1" corresponds to the severity level and can be "informational", "warning" or "error"

    • "%2" corresponds to the alert message containing the license number, the product name and the expiration status

Interactive check

  • Open a command line window

  • Move to the folder you created, example: C:\Charon

  • Execute the powershell script. The following parameters can be passed to the script:

    • "-folder" is used to specify where the scripts (.ps1 and .bat) are stored. If not specified, default is "C:\Charon"

    • "-nbdays" is used to specify the number of days before expiration to start sending alerts, default is 15

    • "-nbhours" is used to specify the number of hours before expiration of a backup/spare license (time limited) to start sending alerts, default is 96. Must not be lower than 72.

    • "-usevanilla" is used in case the hasp_view.exe program is not able to provide the expiration date in the output file (bug found in builds 18304 and 18305 with hasp_view.exe version 1.26). In this case, the script will use the hasp_view.exe program located in the "xxxxx_ORIGINALS_xxx_PATCH_xxx" folder (example: B18302_ORIGINALS_AXP_PATCH_X64). The bug is solved with hasp_view.exe version 1.27 and later.

    • "-haspview <hasp_view.exe location>" is used to specify the location of the hasp_view.exe file. If this parameter is not specified then the script searches for the location itself depending on Charon installation folder. It is used in case a license server performs the checks instead of the server hosting the Charon virtual machines. The "-usevanilla" parameter is ignored if this parameter is defined.

    • "-ini <file>" is used to specify a file where the -folder, -nbdays, -nbhours-usevanilla, -haspview and -tick parameters can be stored. Priority goes to the parameters passed in the command line then those in the specified file. The file is used to facilitate updates in the parameters passed in the tasks scheduler (update the file instead of the task).

    • "-tick" parameter is used to execute external script (expiredlicense.bat) even if no alert is detected (counter alert for monitoring software). If used in the .ini file, "1", "y", "yes" or "true" value activates it, other values will invalidate (Example: tick=true)

 

To run PowerShell scripts (files that end with .ps1), you must first set the execution policy to Unrestricted (This operation has to be done once).

To do so, open a command line window (cmd.exe) as an Administrator and use the following command:
c:\Charon>powershell -command "Set-ExecutionPolicy Unrestricted"

The ExecutionPolicy can also be set to "RemoteSigned". In this case the .ps1 script files will have to be unblocked as described below.

If you are still prompted to allow for execution of the script, please run the following command to unblock the downloaded charon_expchk.ps1 file:
c:\Charon>powershell -command "Unblock-File -path c:\charon\charon_expchk.ps1"

Example:

c:\Charon>powershell -file charon_expchk.ps1 -folder c:\charon -nbdays 20

If the license is not readable (dongle not connected for example), the script will end with an "Unable to generate the license view from hasp_view.exe!" error, an entry will be added to the Windows Event Application log and the expiredlicense.bat script will be executed.

If no script error is detected, it is now possible to create a new scheduled task.

Scheduled task creation

Scheduled task creation using the Graphical User Interface

To set this,

  • either open the Administrative tools under Control Panel and select "Task Scheduler" or

  • execute taskschd.msc from the Windows run command (press Windows key + R)



© Stromasys, 1999-2025  - All the information is provided on the best effort basis, and might be changed anytime without notice. Information provided does not mean Stromasys commitment to any features described. 
Need fast, reliable migration? We have done it countless times. Talk to an expert