Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Windows session programmatically

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?

like image 271
Wolfgang Ziegler Avatar asked Nov 08 '12 11:11

Wolfgang Ziegler


1 Answers

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().

like image 72
Remy Lebeau Avatar answered Oct 12 '22 23:10

Remy Lebeau