Creating a Windows session from a service through the Win32 API

I have a Windows service that can create an executable file in a Windows user session by calling the "CreateProcessAsUser" function. This works great while there is a Windows session. In case I don’t already have one, I would like to create it programmatically. Is it possible? Seems unable to find a function to do this.

+4
source share
3 answers

You cannot create a new session from a service. Sessions are managed by the OS. New users are created when logging in interactively.

+4
source

This is not exactly the solution to the question that I asked, but this solution helped to achieve what I was trying to achieve by asking this question if you understand what I mean.

Instead of having Windows services that create a server session, you can configure windows to automatically log in at boot time. This still means that someone can log out, but heals the main reason for the disappearance of sessions: the server reboots. To activate automatic login, follow these steps:

  • Press the Windows key + R on your keyboard to launch the Run dialog box.
  • Type regedit and press Enter to open the registry editor
  • Then go to HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ WindowsNT \ CurrentVersion \ Winlogon \
  • Set AutoAdminLogon = 1 (create it if its string variable does not exist)
  • Set DefaultUserName = your username (create it if its string variable does not exist)
  • Set DefaultPassword = your password (create it if its string variable does not exist)

Instructions were taken from this post: http://channel9.msdn.com/Blogs/coolstuff/Tip-Auto-Login-Your-Windows-7-User-Account

+3
source
0
source

All Articles