gpt4 book ai didi

java - 从java代码中打开.exe

转载 作者:行者123 更新时间:2023-12-01 14:50:20 25 4
gpt4 key购买 nike

这是我的代码,我想通过Java打开ODBC桥

代码:

   try{
Runtime r = Runtime.getRuntime();
Process p = null;
try{
String s = "C://windows/System32/odbcad32.exe";
p=r.exec(s);
}catch(Exception ex){
System.out.println(ex.getMessage());
}
}catch(Exception ex)
{
System.out.println(ex.getMessage());
}

这就是我面临的问题

Cannot run program "C://windows/System32/odbcad32.exe": CreateProcess error=740, The requested operation requires elevation

最佳答案

您是否尝试编辑 odbcad32 中的连接?如果是这样,我无法帮助您,我在自己的项目中捕获了 SQLException 并使用 Desktop 类打开 obdcad32,如下所示:

Desktop.getDesktop().open(new File("C:\\Windows\\SysWOW64\\odbcad32.exe"));

如果连接到 Access 数据库,这将在 64 位系统上打开 obdcad32。如果您能够连接 64 位驱动程序,那么您可以放弃 SysWOW64 文件夹并将其替换为 System32(或者如果使用 32 位系统。

关于java - 从java代码中打开.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14945449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com