0

我有一大群用户无法从签名的小程序中启动本地创建的文件(PDF、Word 等)。在 Windows 资源管理器中双击文件会启动它,因此与启动应用程序的文件关联是已知的。技术支持在启用了 UAC 的机器上远程登录,发现加载小程序没有问题,并且可以毫无问题地启动本地文件。这让我觉得这个大群体有一个共同的本地环境。用户在 Windows XP(或 7,不确定)上运行 Java 1.6u31。java控制台中没有显示任何错误,也没有任何内容(所有传闻,因为我没有看到问题)。有关可能导致此行为的本地 PC 设置的任何建议?根据代码,问题似乎是支持 Desktop,但 Desktop.Action.OPEN 不支持。任何建议为什么?谢谢。
我正在使用以下内容来启动文件:

            /*
            //old way that would work for Windows prior to Java 1.6
            //cmd = System.getenv("windir") +"\\system32\\"+"rundll32 SHELL32.DLL,ShellExec_RunDLL " + cmd;
            //cmd = "open "+cmd;  // Mac for PDF only?
            //try{
            //  Runtime.getRuntime().exec(cmd);
            //} catch (Exception e) {
            //  //handle error
            //}
            */
            Desktop desktop = null;
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
                if (desktop.isSupported(Desktop.Action.OPEN)) {
                    try {
                        desktop.open(new File(file));
                        return;
                    } catch (IOException e) {
                        //Error launching the file
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(theFrame,
                            "Unable to launch the file.",
                            "Document Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                }
            } else {
                //This OS cannot launch the file
                JOptionPane.showMessageDialog(theFrame,
                        "This operating system is unable" +
                        "\nto launch external files" +
                        "\nfrom within this application.",
                        "Document Error", JOptionPane.ERROR_MESSAGE);
                    return;
            }
4

1 回答 1

0

纯猜测:

1) 受影响的用户都在 Windows 7 上

2)Vista/Win 7“UAC”在咬你:

建议(仅用于诊断):

找到一个受影响的用户,尝试禁用 UAC,看看它是否“突然开始工作”

Control Panel->User Accounts->Turn User Account Control off

==================================================== =================================

2012 年 8 月 24 日附录:

1)我从您随后的注释中了解到,您不仅仅是在尝试执行程序 - 您实际上是在尝试调用 Windows 文件关联(即“shell open”a .pdf 应该触发“AcroReader”的实例) .

2)看这个链接:

3) 更新您的 JDIC(如有必要)

4) 在您的小程序中添加几个测试按钮:

a)“打开”notepad.exe(看看是否可以直接按名称调用.exe)

b)“打开” somefile.txt(看看您是否可以调用任何文件关联 - 例如“.txt”的“记事本”)

5) 如果以上都没有导致解决方案,请直接访问其中一台“失败的 PC”,以便您可以“动手”调试。

'希望有帮助!

于 2012-08-23T21:41:31.970 回答