Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Windows Session from a service via the Win32 API

Tags:

windows

winapi

I have a windows service that can create an executable in the users windows session, via calling the "CreateProcessAsUser" function. This works fine as long as there is a windows session already there. In the case that there isn't one already I'd like to be able to create one programmatically. Is this is possible? Can't seem to find a function to do it.

like image 979
Robert Avatar asked Dec 21 '12 08:12

Robert


1 Answers

This isn't quite the solution for the question I asked, but it was the solution that helped achieve what I was trying to achieve by asking this question, if you see what I mean.

Rather than have having a windows services that creates a server session you can configure windows to automatically logon at boot time. This still means someone could accenditally log off, but cures the main reason for sessions disappearing: the server being rebooted. Use the following steps to activate auto-logon:

  1. Press the Windows key + R on your keyboard to launch the “Run” dialog box.
  2. Type regedit and hit enter to open the Registry Editor
  3. Then browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\
  4. Set AutoAdminLogon = 1 (create it if doesn't exist its a string variable)
  5. Set DefaultUserName = your username (create it if doesn't exist its a string variable)
  6. Set DefaultPassword = your password (create it if doesn't exist its a string variable)

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

like image 92
Robert Avatar answered Sep 30 '22 10:09

Robert