# Removing ScriptModules from ScriptManager

**URL:** <https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430>\
**Category:** Module Development\
**Created:** [June 5, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430 "2024-06-05T17:43:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Zhou](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@Jason\_Zhou](https://forum.inductiveautomation.com/u/Jason_Zhou)\
**Post date:** [June 5, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430/1 "2024-06-05T17:43:41Z")

</div>

Hello, I'm currently developing a third-party Java module that adds additional functions. I'm doing this the exact same way the IA scripting-function example is doing it, by having a ScriptModule, and adding it to the GatewayHook's ScriptManager by calling:  
`manager.addScriptModule("system.example", scriptModule, new PropertiesFileDocProvider());`

Full GatewayHook.java in referenced project linked here: [ignition-sdk-examples/scripting-function/scripting-function-gateway/src/main/java/com/inductiveautomation/ignition/examples/scripting/GatewayHook.java at b2f09134a86ec17320229e1ceffb0c5fecfc7643 · inductiveautomation/ignition-sdk-examples · GitHub](https://github.com/inductiveautomation/ignition-sdk-examples/blob/b2f09134a86ec17320229e1ceffb0c5fecfc7643/scripting-function/scripting-function-gateway/src/main/java/com/inductiveautomation/ignition/examples/scripting/GatewayHook.java)

I'm trying to use a LicenseStateUpdateListener, to listen for a license state update, and to then remove the ScriptModule from the ScriptManager, if the license state is not activated. This is where I'm having trouble. I'm reading the ScriptManager 8.1.42 javadocs and trying things out.

> **[ScriptManager](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.42-rc1/com/inductiveautomation/ignition/common/script/ScriptManager.html)**
>
> declaration: package: com.inductiveautomation.ignition.common.script, class: ScriptManager

I've tried both clearModule() and clearProjectScriptModules(), which both didn't appear to do anything. I've confirmed that a license state update came through as 'Trial', and they were invoked, but I was still able to access and invoke the module scripting functions from a designer.

Does anyone have any pointers to achieve this? Or do I need to be approaching this entirely differently.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 5, 2024, 5:48pm UTC](https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430/2 "2024-06-05T17:48:42Z")

</div>

Don't try to _remove_ script modules. This isn't possible, first of all, and will only lead to _confusion_ from your end users, rather than acceptance of licensing terms.

Instead, take note of the license state update and _in your function implementations_, do something different (throw an error, return an empty list, log a warning, etc) when your module isn't licensed.

---

<div class="post-metadata">

**Author:** ![Jason\_Zhou](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@Jason\_Zhou](https://forum.inductiveautomation.com/u/Jason_Zhou)\
**Post date:** [June 5, 2024, 5:52pm UTC](https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430/3 "2024-06-05T17:52:15Z")

</div>

Gotcha, so following IA's scripting-function example, in GatewayScriptModule.java, how would you recommend having the class have access to license state updates? Or rather, having the class have access to the module's current license state?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 5, 2024, 5:54pm UTC](https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430/4 "2024-06-05T17:54:52Z")

</div>

Your options are myriad, but one possibility:  
When constructing your `GatewayScriptModule` in your gateway hook, pass it a reference back to the `GatewayHook` of your module itself, and capture the current license state there as a field.  
Or you could literally make your GatewayScriptModule a `LicenseStartUpdateListener`.  
Or you could store `GatewayContext` in the `GatewayScriptModule` and use that to go back to the gateway to check license state in your scripting functions.

---

<div class="post-metadata">

**Author:** ![Jason\_Zhou](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@Jason\_Zhou](https://forum.inductiveautomation.com/u/Jason_Zhou)\
**Post date:** [June 5, 2024, 5:59pm UTC](https://forum.inductiveautomation.com/t/removing-scriptmodules-from-scriptmanager/91430/5 "2024-06-05T17:59:03Z")

</div>

Got it, will consider these options and potentially others. Thanks as always Paul.
