如何使用JavaFX桌面应用程序包请求UAC管理权限?

编程入门 行业动态 更新时间:2024-10-26 00:22:02
本文介绍了如何使用JavaFX桌面应用程序包请求UAC管理权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要提升JavaFX桌面应用程序的权限。不是.jnlp或网络版。该程序将部署到桌面上,所以

I need to elevate the permissions of a JavaFX desktop application. Not the .jnlp or the web version. This program will be deployed to desktops so

<fx:deploy ... > <fx:application ... /><fx:resources> ... </fx:resources> <fx:preferences ... /> <fx:info ... /><fx:permissions elevated = "true"/> <!--THIS DOESN'T WORK!!!--> </fx:deploy>

不起作用。我可以让程序在我的IDE中正常运行,当我部署并设置应用程序快捷方式的属性以在Windows中以管理员身份运行程序时,它也能正常工作。

won't work. I can get the program to run fine in my IDE, and when I deploy and set the properties of the application shortcut to run the program as administrator in Windows, that works fine too.

显然,根据我的雇主的说法,无论如何,期望用户这样做是太多了(更改快捷方式属性以管理员身份启动程序)所以我需要另一种解决方案。

Evidently, according to my employer, anyway, it is too much to expect a user to do that (change the shortcut properties to launch the program as administrator) so I need another solution.

那么我需要做什么才能始终使JavaFX应用程序请求管理权限?

So what do I need to do to always make a JavaFX application request administrative privileges?

此外,使用 AccessController.doPrivileged(...)也不起作用。

Also, using AccessController.doPrivileged(...) does not work either.

推荐答案

你可以使用lanuch4j编译jar文件到exe。 将filename.manifest添加到基本/ warpper清单:它将在Windows上作为管理员运行良好。 我已经在我的javafx程序上测试过了。

You can use lanuch4j that compile jar file to exe. add filename.manifest to basic/warpper manifest: it will work well as administrator on windows. I have tested on my javafx program.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="highestAvailable" uiAccess="False" /> </requestedPrivileges> </security> </trustInfo> </assembly>

更多推荐

如何使用JavaFX桌面应用程序包请求UAC管理权限?

本文发布于:2023-11-11 06:49:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577676.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   管理权限   桌面   程序包   JavaFX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!