Java exec 和 rundll32 参数问题

Java exec and rundll32 parameter issue

我在使用 String[] exec 从 Java 启动 Windows 照片查看器时遇到了一个奇怪的问题(实际上我正在使用 Commons Exec 但在内部它会在那里)

    String exec = "C:\WINDOWS\System32\rundll32.exe \"C:\Program Files\Windows Photo Viewer\PhotoViewer.dll\", ImageView_Fullscreen c:\temp\foo.png";   
String[] params = new String[] {"C:\WINDOWS\System32\rundll32.exe", "\"C:\Program Files\Windows Photo Viewer\PhotoViewer.dll\", ImageView_Fullscreen", "c:\temp\foo.png"};
Process process = Runtime.getRuntime().exec(exec);
int result = process.waitFor();
System.out.println(result);

如果我 运行 这个,程序生成得很好但是如果我尝试 exec(params) 我只是 return 立即用 0.

我认为问题出在 "quoted dll" 操作部分附近,但我无法查明它。指针?

提前致谢, 尼克

好像有些引号有误:

dll 的路径可以不用额外的引号来设置。 ImageView_Fullscreen 也可以作为单独的参数提供

String[] params = new String[] {"C:\WINDOWS\System32\rundll32.exe", "C:\Program Files\Windows Photo Viewer\PhotoViewer.dll", "ImageView_Fullscreen", "c:\temp\foo.png"};

这应该会打开文件。