Windows 7 的权限提升?
我有一个 java 应用程序,需要执行驱动程序安装程序 exe 文件。在 Linux 上,我们输入“gksudo myCommand”。有没有办法从 Windows 命令行提升权限?
Ive got a java app which needs to execute a driver installer exe file. On Linux we type "gksudo myCommand". Is there a way to elevate permissions from Windows command line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用不同的用户(例如管理员)运行 Windows 中的每个应用程序。但执行此命令的用户需要拥有执行此操作的凭据。
编辑:
您可以提前查找 Windows 7 和 Vista 中提供的用户帐户控制 (UAC)(如果它可能是您的替代方案)。
You may run every application in windows with a different user e.g. Administrator. But the user who executes this command needs to have the credentials to do so.
Edit.:
In advance you can lookup the User Account Control (UAC) which is available in Windows 7 and Vista if it is possibly an alternative for you.
我决定将一个可执行二进制文件部署到调用该 jar 的系统上。这样用户可以右键单击并以管理员身份运行...这不起作用...所以我一直在寻找...检查一下..
Elevate.exe ..它基本上就像Windows GKSudo!!!!
http://www.robotronic.de/elevate.html
所以...我打包了32位exe 到我的程序中并部署它,然后根据需要运行它。
I decided to deploy an executable binary onto the system which calls the jar. This way the user can right click and run as administrator... That didn't work... SO I kept looking... Check this out..
Elevate.exe.. It's basically like Windows GKSudo!!!!
http://www.robotronic.de/elevate.html
So... I packaged the 32bit exe into my program and deploy it, then run it as necessary.
您可以使用
runas
命令,例如runas /user:Administrator myCommand
(它要求用户输入密码)。您还可以使用
Start-Process
cmdlet,例如 PowerShell 中的Start-Process -Verb runas myCommand
(它要求用户单击 UAC 对话框)。请参阅:http://satob.hatenablog.com/entry/2017/06/ 17/013217
You can use
runas
command likerunas /user:Administrator myCommand
(it requires the users to type password).You can also use
Start-Process
cmdlet likeStart-Process -Verb runas myCommand
in PowerShell (it requires the users to click the UAC dialog).see: http://satob.hatenablog.com/entry/2017/06/17/013217