Create a Windows Session from a service via the Win32 API

后端 未结 4 513
情深已故
情深已故 2021-01-01 03:40

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

4条回答
  •  爱一瞬间的悲伤
    2021-01-01 04:22

    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

提交回复
热议问题