# How to switch to an external application

**URL:** <https://forum.inductiveautomation.com/t/how-to-switch-to-an-external-application/67414>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 9, 2022, 2:47am UTC](https://forum.inductiveautomation.com/t/how-to-switch-to-an-external-application/67414 "2022-12-09T02:47:59Z")\
**Posts on this page:** 1\
**Showing post:** 21

<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:** [December 11, 2022, 10:29pm UTC](https://forum.inductiveautomation.com/t/how-to-switch-to-an-external-application/67414/21 "2022-12-11T22:29:41Z")

</div>

> [@yiotis](#):
>
> file should always be deleted at the _os.path.exists(path)_

Just use `os.remove(path)` to delete the file

> [@yiotis](#):
>
> _"_, I now use _taskName = "DisplayClient.exe"_.

The `.exe` probably won't work in the switching script, so you will probably have to add a second variable. It would look something like this:

```auto
taskName = "DisplayClient.exe"
switchName = "DisplayClient"

```

The isAppRunning function would stay the same, but the second line of your scriptLines array would use switchName instead of taskName.

Putting it all together, the second half of the script would look like the revised code below:

> **Revised Code**
>
> ```auto
> taskName = "DisplayClient.exe"
> switchName = "DisplayClient"
> if isAppRunning(taskName):
> username = getpass.getuser()
> path = "C:/Users/" + username + "/.ignition/cache/tempFile.bat"
> if os.path.exists(path):
> os.remove(path)
> scriptLines = [
> "@echo WScript.CreateObject(\"WScript.Shell\").AppActivate(WScript.Arguments.Item(0))>%tmp%\switch.vbs",
> "%tmp%\switch.vbs \""+switchName+"\"",
> "exit"]
> with open(path, "w") as tf:
> for line in scriptLines:
> tf.write(line + "\n")
> system.util.execute([path])
> 
> ```

> [@yiotis](#):
>
> coffee break for now... I'll experiment with the 2nd portion of the script shortly

This makes perfect sense:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/80913e17236a4749fd7325a632e67576746482f2.png)

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-switch-to-an-external-application/67414)._
