Processing 3.0启动功能无法启动我的.exe。
我正在使用Launch()函数(https://processing.org/reference/launch_.html)
launch("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
或者
launch("C:/app/keyboard.exe");
结果:Chrome浏览器将会打开。 keyboard.exe不会。我尝试了不同的位置和相对路径。 当链接正确时,我只获得一个Windows加载器。这是正确的。
功能描述说: “在尝试打开文件之前一定要使文件可执行(chmod + x)。”
https://superuser.com/questions/106181/equivalent-of-chmod-to-change-file-permissions-in-windows
我还创建了一个.bat文件来执行.exe,但是launch()函数只适用于exe文件。
但这也没有用。
系统:
那么我错过了什么?
答案 0 :(得分:1)
它有点狡猾但适用于Windows 8:
PrintWriter output=null;
output = createWriter("myfile.bat");
output.println("cd "+sketchPath(""));
output.println("start archivo.exe");
output.flush();
output.close();
output=null;
launch(sketchPath("")+"myfile.bat");
您可以选择其他相对路径或绝对路径 例如
output.println(“cd ..”); output.println(“cd directoriy”); ...
答案 1 :(得分:0)
正如Samuil所建议的,Windows使用\
代替/
作为分隔符,您需要将其转义,因此\\
:launch("C:\\app\\keyboard.exe");
< / p>
我建议使用File.separator:
launch("C:"+File.separator+"app"+File.separator+"keyboard.exe");
它有点长,但无论操作系统如何(Linux / OSX / Windows /等)都能正常工作。
exec(new String[]{"start","C:"+File.separator+"app"+File.separator+"keyboard.exe");
也Process。 (如果需要检查输出,可能需要编写自己的线程来管道输出)