简体   繁体   English

在 java 中以管理员身份运行 CMD 无需密码

[英]Run CMD as Administrator in java without password

I need to run the following command using java:我需要使用 java 运行以下命令:

"wmic product where description='" + someProgram + "' uninstall"

This CMD works only when running as Administrator.此 CMD 仅在以管理员身份运行时有效。

This program will run in several machines with different passwords , so I can't insert passwords in my program.该程序将在具有不同密码的多台机器上运行,因此我无法在我的程序中插入密码。

How can I run it as Admin, without running the whole program as administrator?如何以管理员身份运行它,而不以管理员身份运行整个程序?

Edit:编辑:

This program runs on a local Windows machine (no dealing with remotes)该程序在本地 Windows 机器上运行(不处理遥控器)

I believe it is possible in Unix for your Admin to write to write a Shell Script which runs with the priveleges of another User-ID & which members of the Group (or Anyone) may start.我相信在 Unix 中,您的管理员可以编写一个 Shell 脚本,该脚本以另一个用户 ID 的权限运行,并且该组的成员(或任何人)可以启动。

See: Setuid & chmod请参阅:Setuid 和 chmod

If you are looking for a remote solution (where the Java makes say an SSH connection to the remote and then runs the command), then can't you configure the process running on those machines - providing the SSH server - so it runs commands as an appropriately privileged user?如果您正在寻找远程解决方案(其中 Java 说 SSH 连接到远程然后运行命令),那么您不能配置在这些机器上运行的进程 - 提供 Z765553E6C7AC8592C389ACB 的命令运行为 78050 服务器 -AAZ适当的特权用户?

AND/OR find a localgroup that gives the permissions you need?和/或找到一个提供所需权限的本地组?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM