How do I request UAC administrative privileges with a JavaFX desktop application bundle?

拥有回忆 提交于 2019-12-11 12:26:26

问题


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>

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.

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

EDIT:

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


回答1:


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>  


来源:https://stackoverflow.com/questions/27332003/how-do-i-request-uac-administrative-privileges-with-a-javafx-desktop-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!