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

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

问题描述

是否可以在具有不同用户帐户的Windows上创建新进程?我知道有一个上下文菜单Run as但我想用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.

推荐答案

您需要使用 Java本地接口(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天全站免登陆