在Java中更改Windows用户
是否可以使用Java设置不同的Windows用户? 我有以下问题:
我的应用程序以管理员身份执行编写的程序。但是,在某一时刻我需要切换 Windows 用户以便从命令行执行程序(该程序只能由该用户访问 - 由于其许可证,我无法以管理员身份启动它)。
因此,为了简化解释,我需要做以下事情:
- 作为管理员
- 登录启动程序,当不同的用户
- 从命令行执行程序时
- 从用户注销,以管理员身份登录
- 继续执行程序直到最后
我做了除了以用户身份登录之外的所有操作。程序运行在vps服务器上。
我正在谷歌搜索但找不到正确的解决方案。
Is it possible to set a different windows user with Java?
I have following issue:
My application executes written program as admin. However, at one point I need to switch windows user in order to execute program from the command line (this program can only be accessed by this user - I cannot start it as admin due to its license).
So to simplify explanation i need to do following things:
- start program as admin
- login at one point as different user
- execute program from command line
- logout from user, login as admin
- continue to execute program till the end
I did everything except logged in as user. Program runs on vps server.
I was googling but couldn't find the right solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Linux 中,我们有
su
来实现此目的,我不确定 Windows,但这个博客似乎做到了。
还有
这里
从 java 来源
In Linux we have
su
for this,I am not sure about windows but this blog seems doing it.
further
here is code snippet to execute native commands from java
Source