我想执行一个 setup.exe 安装程序,用 java 1.6 在 vista 上安装一个软件。
用户不是管理员。当我尝试启动该过程时,我收到错误消息:
CreateProcess error=740
这表示用户没有足够的权限来启动该进程。
我可以提交一个标志或选项来表明该进程应该以管理员权限执行吗? Vista 本身在菜单工具栏中确实具有此功能。我可以在 Java 中使用这个函数吗?
我调用了下面的代码
Runtime rt = Runtime.getRuntime();
Process process;
try {
String fileToExecute = new File(mFolder, mSetupFiles[0]).getCanonicalPath();
if (logger.isDebugEnabled()) {
logger.debug("Execute runtime process");
}
process = rt.exec(fileToExecute, null, mFolder);
process.getErrorStream().close();
process.getInputStream().close();
process.getOutputStream().close();
if (logger.isDebugEnabled()) {
logger.debug("Wait until process is finished");
}
process.waitFor();
} catch (IOException e) {
throw new StartException(e);
} catch (InterruptedException e) {
throw new StartException(e);
}
最佳答案
关于java - 在 Vista 上以管理员权限启动 Java 运行时进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1420901/