# Using the launch() function anomaly

**URL:** https://discourse.processing.org/t/using-the-launch-function-anomaly/40573
**Category:** Processing
**Created:** [January 13, 2023, 6:54am UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573 "2023-01-13T06:54:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![markcosmic](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@markcosmic](https://discourse.processing.org/u/markcosmic)
#### Post date: [January 13, 2023, 6:54am UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/1 "2023-01-13T06:54:42Z")

</div>

Using the launch() function does launch the already compiled sketch. But the compiled sketch ends/exits immediately. I wasn’t sure launch() was working until I set the flag in the properties of the compiled sketch to “Run as Administrator”. The usual alert popped up asking if I want to allow the app to make changes to my device. I click “Allow” and the compiled sketch starts and shuts down in a blink. I can run the compiled sketch no problem, but not from within a sketch.  
Anyone experiencing this?  
Any thoughts?  
Thanks

---

<div class="post-metadata">

### Author: ![markcosmic](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@markcosmic](https://discourse.processing.org/u/markcosmic)
#### Post date: [January 14, 2023, 7:17pm UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/2 "2023-01-14T19:17:08Z")

</div>

I’m using Processing 4. I created a new sketch just to launch() a exported sketch(.exe file). I used a different compiled sketch than the one I previously tried and received the same results.

---

<div class="post-metadata">

### Author: ![markcosmic](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@markcosmic](https://discourse.processing.org/u/markcosmic)
#### Post date: [January 31, 2023, 3:57am UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/3 "2023-01-31T03:57:59Z")

</div>

After further checking, I found the launch() function will launch, say “C:\Windows\System32\notepad.exe”, but will not launch any of the exported sketches (“.exe” files) I created.  
I’m hoping to find an answer to this anomaly  
Any thoughts would be appreciated

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [January 31, 2023, 2:59pm UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/4 "2023-01-31T14:59:53Z")

</div>

Hi @markcosmic,

you need to be in the same directory as the executable, resp. the working directory needs to be set to.  
So on windows you can call it like that …

`launch("cd /d <drive>:<path_to_sketch_exe> && <executable_name>.exe");`

This should work. If not, you can trace the issue by using

```auto
Process p = launch("cd /d <drive>:<path_to_sketch_exe> && <executable_name>.exe");
try {
   p.getErrorStream().transferTo(System.err);
} catch (Exception e) {
   println("Error on Stream: " + e)
}

```

Cheers  
— mnse

PS: remember to use `\\` for `\` on path string. ie: `cd C:\\MyDir\\etc\\`

---

<div class="post-metadata">

### Author: ![markcosmic](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@markcosmic](https://discourse.processing.org/u/markcosmic)
#### Post date: [January 31, 2023, 8:19pm UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/5 "2023-01-31T20:19:48Z")

</div>

mnse,  
Thank you for responding. I am aware of the launch(parameters).  
This is what I tried:

case 5: //launch Create PlayList  
//createPlayList(); (this links the ChatGPT suggested way to do it)  
//launch(“C:\Windows\System32\notepad.exe”); //THIS WORKED

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [January 31, 2023, 9:18pm UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/6 "2023-01-31T21:18:34Z")

</div>

Hi @markcosmic,

_Please read my post carefully to get the point._

If you start notepad.exe you are not dependent of a working dir. This is different for starting the sketch executable.

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![markcosmic](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@markcosmic](https://discourse.processing.org/u/markcosmic)
#### Post date: [January 31, 2023, 10:42pm UTC](https://discourse.processing.org/t/using-the-launch-function-anomaly/40573/7 "2023-01-31T22:42:20Z")

</div>

Thank you. I got it. This is what worked for me. I didn’t want to hard code a location.

launch(“cd /d” + dataPath(“&& PlayList03.exe”));

Again,  
Thank you
