Zip*_*pyV 20
您必须创建一个清单文件,指定您的应用程序需要管理员权限.您可以在您的exe中包含清单或将其保存为单独的文件(yourapp.exe.manifest)
http://msdn.microsoft.com/en-us/library/bb756929.aspx
小智 9
最简单的方法是使用包装器启动JVM,然后提升包装器.我使用UAC插件的简单NSIS安装程序脚本来执行此操作:
; Java Launcher
;--------------
; You want to change the below lines
Name "my program"
Caption "my program Launcher"
Icon "iconfile.ico"
OutFile "java launcher.exe"
; param below can be user, admin
RequestExecutionLevel admin
!include UAC.nsh
SilentInstall silent
AutoCloseWindow true
ShowInstDetails show
Section ""
; command to execute
StrCpy $0 'javaw -jar myjarfile'
SetOutPath $EXEDIR
Exec $0
SectionEnd
Run Code Online (Sandbox Code Playgroud)
您可以使用Windows程序来提升您的权限.程序将显示UAC提示符,然后您将拥有管理员权限.
http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/
然后你可以运行这样的命令:
Runtime.getRuntime().exec("Elevate.exe yourcommand");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
89819 次 |
| 最近记录: |