Run .exe file with launch()


#1

hi
i want run an exported exe file in processing.i copy that to my pde adress.when run exe file in cmd run perfect.but when use launch() or exec() don,t run and don,t say any errors.what is my mistake?
my code:
void setup(){
size(500,500);
exec((“C:/Users/ToNy/Desktop/aa/application.windows64/az2d_noise.exe”));
}
void draw (){
}


#2

my exe file destination:


#3

Check this post. You need to create a bat file and then call this file within Processing using exec().

Kf


#4

hi kf
thanks for your attention.i see your sent link but can’t understand which way make .bat file and what is that’s contain?
please help me
best


#5

You are trying to execute one sketch from another sketch. I tried the link above before on Win10 and it worked.

Your sketch would look something like

void setup () {
  size(500,500);
  runMyExec();
}

void draw() { 
  // press mouse button inside sketch window to launch external application
}


void runMyExec() {
  String fn="myfile.bat";
  PrintWriter output=null;
  output = createWriter(fn);
  output.println("C:\\Users\\ToNy\\Desktop\\aa\\application.windows64\\");
  output.println("start  az2d_noise.exe");
  output.flush();
  output.close();  
  output=null;
  launch(sketchPath("")+fn);
  //REFERENCE: //http:// stackoverflow.com/questions/33974730/processing-3-0-launch-function-doesnt-launch-my-exe
}

Kf


#6

wooooooooow thanks for your kindly answer.i run your codes but have this error:
“windows can not find az2d_noise.exe.make sure you typed the name correctly and then try again”
but I write correct the name and when in cmd run the az2d_noise.exe in C:\Users\ToNy\Desktop\aa\application.windows64 address run file perfect .
may help me what is my mistake
tnx


#7

I had a typo in my previous post. You need the change directory command:

output.println("cd C:\\Users\\ToNy\\Desktop\\aa\\application.windows64\\");

Sorry about that,

Kf


#8

hi
I use cd in address but have before error.windows can not find az2d_noise.exe.make sure you typed the name correctly and then try again"
I copy application.windows64 folder contains my exe file near the .pde file that want to run exe from it.
is that Right?


#9

hi
when I change the progrom as codes below when click on myfile.bat run the exe fie perfect but when run the .pde don’t have any errors but only saw a gray window and don’t run the exe file.i think my mistake is in this line launch((“C://Users//ToNy\Desktop\aa”)+fn); " for address but can’t understand what was write for the address

void draw() {
// press mouse button inside sketch window to launch external application
}

void runMyExec() {
String fn=“myfile.bat”;
PrintWriter output=null;
output = createWriter(fn);

output.println("cd C:\\Users\\ToNy\\Desktop\\aa\\application.windows64\\");

output.println(“start az2d_noise.exe”);
output.flush();
output.close();
output=null;
launch((“C://Users//ToNy\Desktop\aa”)+fn);
//REFERENCE: //http:/drawing/ stackoverflow.com/questions/33974730/processing-3-0-launch-function-doesnt-launch-my-exe
}


#10

void setup () {
size(500,500);
runMyExec();
}

void draw() {
// press mouse button inside sketch window to launch external application
}

void runMyExec() {
String fn=“myfile.bat”;
PrintWriter output=null;
output = createWriter(fn);

output.println("cd C:\\Users\\ToNy\\Desktop\\aa\\application.windows64\\");

output.println(“start az2d_noise.exe”);
output.flush();
output.close();
output=null;
launch((“C://Users//ToNy\Desktop\aa”)+fn);
//REFERENCE: //http:/drawing/ stackoverflow.com/questions/33974730/processing-3-0-launch-function-doesnt-launch-my-exe
}


#11

@azizeh.aghaee
The above line is not right. Back slash ‘’ character has a special meaning in different programs. It is called a escape character meaning that it allows to access other characters not accessible via your physical keyboard. For instance \t is the TAB character and ‘\n’ is the new line character. In your line above, you need to replace single back slash characters with two of them like this: \\. With this change, the system will interpret this change as a real standard back slash character. I hope I am not confusing you. In a nutshell, your line above should be:

launch((“C:\\Users\\ToNy\\Desktop\\aa\\”)+fn);

OR

launch((“C:/Users/ToNy/Desktop/aa/”)+fn);

Notice forward slashes / are interpreted as what they are. Sorry for the late reply. I do not check this forum as often.

Kf


#12

hi
thanks for your pay attention.
when use launch((C:/Users/ToNy/Desktop/aa/â€‌)+fn); don’t see any error but don’t run the exe file too.
and when double back slash ,don’t see any error but don’t run the exe file too.


#13

when click on drawing.bat run the program perfect.but when execute the pde and write. launch((“D:\sa”)+fn); don’t run exe file and don’t have any error too.but when write launch((“D:\sa\”)+fn); use double slash in the end have this error that
a "


I can not understand where is my mistake
Special thanks for your kindly answers kfrajer


#14

Based on what you posted in your previous post, the problem could be:

output=createWriter(fn);

and

launch("D:\\sa\\" + fn);

I believe the first line is creating the file most likely in the data folder. The second line is trying to retrieve the bat file from an absolute data path and it wont be the same as described by the first line.

To solve it, I propose you implement the following changes in your code:

  1. fn = "D:\\sa\\" + fn;

  2. output=createWriter(fn);

  3. launch(fn);

In other words, you save and retrieve always based on absolute paths.

Kf


#15

hi
I use this code but havepervious error that can,t find drawing.exe
my code:
void setup () {
size(500,500);
runMyExec();
}

void draw() {
// press mouse button inside sketch window to launch external application
}

void runMyExec() {
String fn=“myfile.bat”;
PrintWriter output=null;
fn = “D:\sa\” + fn;
output = createWriter(fn);
output.println(“cd d:\sa\application.windows64”);
output.println(“start drawing.exe”);
output.flush();
output.close();
output=null;
launch(fn);
}


#16

this my code too have previous error too that can’t find drawing,exe

void setup () {
size(500,500);
runMyExec();
}

void draw() {
// press mouse button inside sketch window to launch external application
}

void runMyExec() {
String fn=“myfile.bat”;
PrintWriter output=null;
fn = “D:\sa\” + fn;
output = createWriter(fn);
output.println(“cd d:\sa\application.windows64”);
output.println(“start drawing.exe”);
output.flush();
output.close();
output=null;
launch(fn);
}


#17

I use \ between address but when post the code show \
in code above I use
fn = " d:\sa\ + fn;
and
“cd d:\sa\application.windows64”


#18

I mean use double slash but don’t understand why send the post to froum only show one slash


#19

You are not getting the proper input values here in the forum because you are not formatting your code. To format your code, you need to enclose your code in triple back ticks like this:

```
Some code here
```

Notice there is an empty line before and after the triple back ticks. The reason you use this is because this forum uses markdown for posting. You can google it to find out more about how it works. It is really simple. You just need to see some demonstrations.

Related to your question, can you open a command prompt in your sketch folder and get the structure of your folder. Just do this in a command window:

cd d:\sa
tree /f /a

What do you get?

Kf


#20

hi dear kf
especially thanks for your attention and help
when do cd d:sa and ```
tree /f /a