# Client Event Startup Script invokeLater

**URL:** <https://forum.inductiveautomation.com/t/client-event-startup-script-invokelater/68512>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 11, 2023, 8:27pm UTC](https://forum.inductiveautomation.com/t/client-event-startup-script-invokelater/68512 "2023-01-11T20:27:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [January 11, 2023, 8:35pm UTC](https://forum.inductiveautomation.com/t/client-event-startup-script-invokelater/68512/2 "2023-01-11T20:35:19Z")

</div>

Further info:

I only started trying to close the window after a delay after it seemed the last line of the previous version on my script was not doing anything:

```auto
user = system.security.getUsername()
if user == 'Guest':
	tagPaths = ["[System]Client/Network/Hostname"]
	tag = system.tag.readBlocking(tagPaths)
	if tag[0].value == 'MyPC':
		success = system.security.switchUser('username', 'password')
		if success:
			windowPath = 'User Management/Switch User'
			system.nav.closeWindow(windowPath)

```

And I added the import system to the defined function because I was getting this error without it:

> Traceback (most recent call last):  
> File "", line 15, in   
> File "", line 14, in closeWindow  
> NameError: global name 'system' is not defined
> 
> at org.python.core.Py.NameError(Py.java:261)  
> at org.python.core.PyFrame.getglobal(PyFrame.java:265)  
> at org.python.pycode.\_pyx2.closeWindow$1(:14)  
> at org.python.pycode.\_pyx2.call\_function()  
> at org.python.core.PyTableCode.call(PyTableCode.java:173)  
> at org.python.core.PyBaseCode.call(PyBaseCode.java:134)  
> at org.python.core.PyFunction. **call** (PyFunction.java:416)  
> at org.python.pycode.\_pyx2.f$0(:16)  
> at org.python.pycode.\_pyx2.call\_function()  
> at org.python.core.PyTableCode.call(PyTableCode.java:173)  
> at org.python.core.PyCode.call(PyCode.java:18)  
> at org.python.core.Py.runCode(Py.java:1687)  
> at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:800)  
> at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:769)  
> at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:736)  
> at com.inductiveautomation.factorypmi.application.FPMIApp.startup(FPMIApp.java:486)  
> at com.inductiveautomation.factorypmi.application.runtime.ClientPanel.lambda$startupApp$8(ClientPanel.java:881)  
> at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)  
> at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)  
> at java.desktop/java.awt.EventQueue$4.run(Unknown Source)  
> at java.desktop/java.awt.EventQueue$4.run(Unknown Source)  
> at java.base/java.security.AccessController.doPrivileged(Native Method)  
> at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)  
> at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)  
> at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)  
> at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)  
> at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)  
> at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
> at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
> at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
> 
> Ignition v8.1.21 (b2022092908)  
> Java: Azul Systems, Inc. 11.0.15

and I found a [forum thread](https://forum.inductiveautomation.com/t/global-name-system-is-not-defined/) that told me to import system.

---

_[View the full topic](https://forum.inductiveautomation.com/t/client-event-startup-script-invokelater/68512)._
