# How to Run Startup Script in Vision Designer

**URL:** <https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [March 17, 2025, 3:52am UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762 "2025-03-17T03:52:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [March 17, 2025, 3:52am UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/1 "2025-03-17T03:52:08Z")

</div>

Script in internalFrameActivated and visionWindowOpened works perfect on vision client.

But not running on designer.  
Is there a way to run startup script on vision designer?

---

<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:** [March 17, 2025, 12:02pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/2 "2025-03-17T12:02:31Z")

</div>

You have to be in preview mode when you open the window.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [March 17, 2025, 12:07pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/3 "2025-03-17T12:07:10Z")

</div>

I think for startup of designer there's some trick if I recall of making a vision client tag with an on change script that will fire when designer is opened.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [March 17, 2025, 2:01pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/4 "2025-03-17T14:01:25Z")

</div>

Thank you for your quick responses, otherwise I will keep thinking how to make this work.

In this vision window, I have an action to write component value to document tag.

If this component value doesn't update on window startup on designer, a developer will unintentionally write old designer value to document tag.

Instead, I will modify my strategy to bind component values to tag.

---

<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:** [March 17, 2025, 2:15pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/5 "2025-03-17T14:15:03Z")

</div>

> [@Eugene49](#):
>
> will modify my strategy

Wise. I never use those window events, for similar reasons.

In a pinch you can use `runScript()` in a run-once binding to execute a script no matter what mode the designer is in.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [March 17, 2025, 2:38pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/6 "2025-03-17T14:38:45Z")

</div>

> [@pturmel](#):
>
> In a pinch you can use `runScript()` in a run-once binding to execute a script no matter what mode the designer is in.

Can you tell me more where is this run-once binding?

I've never encountered a run-once binding anywhere within ignition.

---

<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:** [March 17, 2025, 3:01pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/7 "2025-03-17T15:01:59Z")

</div>

This will run the target function once:

```python
runScript("path.to.some.function", 0)

```

Same as the behavior of `now(0)` to capture a startup timestamp. These are "polling" functions that will only run once if the poll interval is set to zero. As documented.

Bindings that have no references to any other tag or property, and do not poll, will only execute once.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [March 17, 2025, 5:10pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/8 "2025-03-17T17:10:30Z")

</div>

I found how I am doing it currently now that I'm at my office.

1. Create a vision client tag with a type of DateTime
2. Set tag to use expression `now(0)`
3. Set the Value Changed event script to this and add your script inside the if block:

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	# If this is the first event after initial subscription and if the event is in the designer environment,
	if initialChange and system.tag.readBlocking(['[System]Client/System/SystemFlags'])[0].value < 4:
		# Put your script/code here that you want to run one time on startup of the designer

```

---

<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:** [March 17, 2025, 5:45pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/9 "2025-03-17T17:45:07Z")

</div>

The OP is looking to run a script on **window** startup, not **client** startup.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [March 17, 2025, 6:07pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/10 "2025-03-17T18:07:32Z")

</div>

Ahh, from reading the OP this morning, I thought they meant on designer startup. In all honesty, I just kinda glanced at the other messages to make sure I wasn't repeating something someone else already posted. Looking back now, I see they're talking about a window.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 20, 2025, 7:47pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/11 "2025-03-20T19:47:29Z")

</div>

Add a custom property called `isRunning` and bind it to system flags:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/93b72bb4cb1b39d6aa42f8b01c05333ac7c70842.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/05fcb730e660cabe5dc043654d00ec882af987c6.png)

```python
//expression binding on the isRunning custom property
{[System]Client/System/SystemFlags} > 2

```

Then, run your initialization script on the `propertyChange` event handler:

```python
# Custom Property that allows the change to be visible in the designer
# ...without having to close and reopen the window
if event.propertyName == 'isRunning' and event.newValue:
	# Do initialization stuff here

```

Any time preview mode is started or a client session is initialized, the tag value will change to a value greater than two and trigger the script.

---

<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:** [March 20, 2025, 8:25pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/12 "2025-03-20T20:25:46Z")

</div>

> [@justinedwards.jle](#):
>
> custom property called `isRunning` and bind it to system flags:  
> ....

That's a lot more trouble than just calling a custom method from a `runScript()` binding on a custom property in a window's root container. `self` in the custom method will be the root container.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 20, 2025, 8:35pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/13 "2025-03-20T20:35:09Z")

</div>

> [@pturmel](#):
>
> That's a lot more trouble

Simply triggering a property change event from a tag binding doesn't seem like more trouble that creating a custom method and calling it from a runscript expression binding. It's just clear and clean coding approach that doesn't use run script.

---

<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:** [March 20, 2025, 8:37pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/14 "2025-03-20T20:37:04Z")

</div>

Bindings with `runScript()` work in both design and preview mode. All other scripts only work in preview mode. The OP wants a script that will run on window open in the designer whether in design or preview mode.

🤷‍♂️

{ Your code also will run every time they change from design to preview. That isn't "run once". }

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 20, 2025, 8:56pm UTC](https://forum.inductiveautomation.com/t/how-to-run-startup-script-in-vision-designer/103762/15 "2025-03-20T20:56:31Z")

</div>

> [@pturmel](#):
>
> Your code also will run every time they change from design to preview

Exactly; I like that when I'm developing.
