执行Java程序以管理员身份 [英] Executing Java program as administrator

查看:1732
本文介绍了执行Java程序以管理员身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Set UAC = CreateObject("Shell.Application")  
UAC.ShellExecute "C:\Users\Biebs\Desktop\New folder\Loader.bat", "ELEV", "", "runas", 1

我试图执行一个Java文件作为管理员,这其中需要一个终端所以这将是有点困难,然后只需运行在管理员的CMD瓶子里。

I'm trying to execute a Java file as an administrator, this one requires a terminal so it will be a little harder then simply running the Jar in an administrator's cmd.

我有一个Java装载器执行类文件的Java程序。我试图运行装载机作为管理员,它给了我一个无法找到或加载主类的错误。所以,我发现了一个VBS脚本,将执行批处理作为管理员,然而这仍然没有奏效。但是我只想澄清,当我运行加载器它完全是非管理员。我怎么能执行一个Java程序,需要一个终端,这样我就可以拥有管理员权限。

I have a Java loader that executes the class file to the java program. I tried to run the loader as an Administrator, it gives me a 'cannot find or load main class' error. So I found a VBS script that would execute the batch as an administrator, however this still didn't work. However just to clarify, when I run the loader as a non administrator it works perfectly. How can I execute a java program, that requires a terminal, so I can have administrator rights.

推荐答案

的Java:以管理员身份运行帮助解决我的问题。只要确保到Elevate.exe添加到您的源文件夹(其中的.class和.java文件),随后可以通过使用此code执行所有管理员命令...

Java: run as administrator helped to solve my problem. Just make sure to add the Elevate.exe into the folder of your source (where the .class and .java files are), afterwards all administrator commands can be executed by using this code...

Runtime.getRuntime().exec("Elevate.exe yourcommand");

由于用户mathd张贴了...

Thanks to user mathd for posting that...

该ELEVATE程序可以在找到http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/ 。感谢所有谁帮助:)

The elevate program can be found at http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/ . Thanks to all who helped :)

这篇关于执行Java程序以管理员身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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