问题描述
当我尝试通过Java ProcessBuilder类在任务调度程序中创建一个新任务时,我得到一个访问被拒绝错误的Windows Vista。在XP上,它工作得很好。
When I try to create a new task in the task scheduler via the Java ProcessBuilder class I get an access denied error an Windows Vista. On XP it works just fine.
当我使用Run as adminstrator选项时,它也可以在Vista上运行..
When I use the "Run as adminstrator" option it runs on Vista as well..
然而,这是一个额外的步骤,用户可能不知道这一点。当用户只需双击应用程序图标时,它将失败并拒绝访问。我的问题是如何在启动后立即强制java应用程序重新获取管理员权限?
However this is a additional step requeried an the users might not know about this. When the user just double clicks on the app icon it will fail with access denied. My question is how can I force a java app to reuest admin privileges right after startup?
推荐答案
我不确定你能否以编程方式进行。如果您的应用程序有安装程序,则可以添加注册表项以强制运行为admin:
I'm not sure you can do it programmatically. If you have an installer for your app, you can add the registry key to force run as admin:
密钥:<< exe的完整路径>>
Key: << Full path to exe >>
价值:RUNASADMIN
Value: RUNASADMIN
类型:REG_SZ
这篇关于在Windows Vista上请求Java应用程序的管理员权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!