以编程方式创建 Windows 会话 [英] Create Windows session programmatically

查看:74
本文介绍了以编程方式创建 Windows 会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 服务 (0) 会话中运行了一项服务.从客户端连接后,我需要为给定的用户凭据创建一个新的 Windows 会话,登录该用户并在此新会话中启动应用程序.

I have a service running in the Windows services (0) session. Upon connection from a client I need to create a new Windows session for given user credentials, log in that user and start an application into this new session.

有没有办法以编程方式为给定的用户凭据创建用户会话?

Is there a way to programmatically create a user session for given user credentials?

推荐答案

AFAIK,您不能以可编程方式创建会话.为此,客户端必须使用终端服务或远程桌面连接到计算机.但是,如果您只需要以该用户身份运行进程而不使其在屏幕上可见,您可以通过编程方式登录到用户帐户并模拟它.查看 LogonUser()ImpersonateLoggedOnUser()CreateProcessAsUser()CreateProcessWithLogonW().

AFAIK, you cannot create sessions programmably. The client would have to connect to the machine using Terminal Services or Remote Desktop for that. You can, however, programmably log in to a user account and impersonate it if you just need to run a process as that user without making it visible to the screen. Look at LogonUser() and ImpersonateLoggedOnUser(), CreateProcessAsUser(), or CreateProcessWithLogonW().

这篇关于以编程方式创建 Windows 会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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