# runScript on Client Event Scripts -\> Startup

**URL:** <https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604>\
**Category:** Ignition\
**Created:** [October 9, 2017, 7:35am UTC](https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604 "2017-10-09T07:35:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ionuck](https://avatars.discourse-cdn.com/v4/letter/i/3d9bf3/32.png) [@ionuck](https://forum.inductiveautomation.com/u/ionuck)\
**Post date:** [October 9, 2017, 7:35am UTC](https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604/1 "2017-10-09T07:35:09Z")

</div>

Hi,

I’m trying to run a security script on Client Event Scripts -\> Startup for a specific user that will grant the user to open only the specified windows in the project, but it’s not working.  
Code below:

script name: project.Security

def clearance():  
name = system.security.getUsername()  
if name == ‘john’:  
system.nav.openWindow(“Main Window”)  
system.nav.openWindow(“SEAU Sighet”)  
else:  
(“You don’t have the permission to access the page!!”)

On Client Event Scripts -\> Startup:  
runScript(“project.Security”)

Any idea, please?

Thank you.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 9, 2017, 11:25am UTC](https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604/2 "2017-10-09T11:25:35Z")

</div>

in the startup script you call the other script, you don’t use runscript.

project.Security.clearance()

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 9, 2017, 12:47pm UTC](https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604/3 "2017-10-09T12:47:47Z")

</div>

Also note that shared and project scripts are _modules_, not simple scripts. Modules are imported by the script manager, running just once, and the functions and variables defined within persist until the script is edited and therefore reloaded. Trying to execute “project.Security” is automatically a mistake. Execution must always have the form “project.someModule.someFunction()”. (Variables and bare callables would omit the parens, of course.)

---

<div class="post-metadata">

**Author:** ![ionuck](https://avatars.discourse-cdn.com/v4/letter/i/3d9bf3/32.png) [@ionuck](https://forum.inductiveautomation.com/u/ionuck)\
**Post date:** [October 10, 2017, 6:44am UTC](https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604/4 "2017-10-10T06:44:17Z")

</div>

I tried the code below and it runs ok in the Script console, but it’s not opening the requested page when logging in.  
Is it because I have a main window activated that opens when logging in ?

def clearance():  
name = system.tag.getTagValue("[System]Client/User/Username")  
if name == ‘admin’:  
system.nav.openWindow(‘Old Sensors’)  
else:  
system.gui.errorBox(‘You don’t have access to this window!!’)

In Startup: project.Security.clearance()

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [October 10, 2017, 8:27pm UTC](https://forum.inductiveautomation.com/t/runscript-on-client-event-scripts-startup/15604/5 "2017-10-10T20:27:42Z")

</div>

The normal function to return a tag value is:

`name = system.tag.read("[System]Client/User/Username").value`

or as you did above to get the currently logged in user:

`name = system.security.getUsername()`

Both should return the Username logged in to the client. However, when you run this script in the Script console, it will return the name of the user logged in to the Designer. Are you sure that ‘admin’ is logged in to the client when it runs this on start-up?
