UAC和Java [英] UAC and Java

查看:149
本文介绍了UAC和Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从Java应用程序中请求提升权限?我看到的建议似乎都集中在运行外部可执行文件或设置清单以请求启动权限。例如,这些小程序不可用。有没有办法从正在运行的应用程序请求提升?

Is it possible to ask for elevated permissions from within a Java Application? Suggestions I've seen seem to all be centered around running an external executable or setting up a manifest to request privileges on launch. These aren't available to, for instance, applets. Is there any way to request elevation from a running application?

推荐答案

UAC不是正在运行的进程可以请求的(不是'无论你在运行什么语言)。您必须在发布时请求提升。

UAC is not something that a running process can request (doesn't matter what language you are running in). You have to request elevation at launch time.

大多数Windows应用程序处理此问题的方式(并使其看起来,就像他们要求提升一样)是生成自己的额外副本,请求提升,并将足够的命令行参数传递给新进程,以便显示相应的对话框。

The way that most windows apps handle this (and make it look like they are requesting elevation) is to spawn an extra copy of themselves, requesting elevation, and passing sufficient command line arguments to the new process so that the appropriate dialog can be displayed.

这就是为什么UAC对话框中的高程始终通过按钮单击启动,打开一个新对话框。

This is why UAC elevation in a dialog is always initiated by a button click that opens a new dialog.

因此,在Java世界中,您只需要完全按照其他人的要求执行操作。执行:再次启动您的应用,请求提升。有几种方法可以启动提升,'run as'动词可能是最简单的。

So, in the Java world, you just have to do exactly what everyone else has to do: launch your app again, requesting elevation. There are several ways to launch elevated, the 'run as' verb probably being the easiest.

这篇关于UAC和Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆