我正在尝试通过 Java 程序启动 .exe 文件。我使用了以下代码:
System.out.println("Opening " + path);
Process exec;
exec = Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + path);//path is the path of the exe file which is passed as an argument from another java class
输出如下:
打开 C:\Program Files (x86)\C-Free 5\CppIDE.exe
但它没有打开。
相反,当我尝试
String pat="C:\\Program Files (x86)\\C-Free 5\\CppIDE.exe";
Process exec;
exec = Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + pat);
程序打开。
我不知道问题是什么。