我需要提升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管理权限?
发布评论