如何在 Windows 上使用另一个用户帐户创建新进程? [英] How can I create a new process with another User Account on Windows?

查看:26
本文介绍了如何在 Windows 上使用另一个用户帐户创建新进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用不同的用户帐户在 Windows 上创建新进程?我知道有一个上下文菜单运行方式",但我想从 Java 中进行.我有用户名和密码.

Is it possible to create a new process on windows with a different user account? I know there are a context menu "Run as" but I want do it from Java. I have the username and the password.

推荐答案

您需要使用 编写 DLLJava 本机接口 (JNI),因为您无法使用纯 Java 代码执行此操作.

You need to write a DLL using the Java Native Interface (JNI) as you cannot do this with pure Java code.

DLL 本身需要调用 CreateProcessAsUser 函数在另一个用户的上下文中创建一个进程.要成功创建该过程,您需要向该函数提供访问令牌,该令牌本身是通过调用 LogonUser 函数(需要用户名和密码来验证其他用户).

The DLL itself needs to call the CreateProcessAsUser function to create a process in the context of another user. To successfully create that process you need to provide an access token to the function, which was itself created by calling the LogonUser function (it takes the username and password to authentify that other user).

这篇关于如何在 Windows 上使用另一个用户帐户创建新进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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