通过 Win32 API 从服务创建 Windows 会话 [英] Create a Windows Session from a service via the Win32 API

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

问题描述

我有一个 Windows 服务,它可以通过调用CreateProcessAsUser"函​​数在用户 Windows 会话中创建一个可执行文件.只要那里已经有一个 Windows 会话,这就可以正常工作.如果还没有一个,我希望能够以编程方式创建一个.这是可能的吗?似乎找不到执行此操作的函数.

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.

推荐答案

这不是我提出的问题的完全解决方案,但它是通过提出这个问题帮助实现我试图实现的目标的解决方案,如果你明白我的意思.

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.

无需使用创建服务器会话的 Windows 服务,您可以将 Windows 配置为在启动时自动登录.这仍然意味着有人可能会意外注销,但解决了会话消失的主要原因:服务器重新启动.使用以下步骤激活自动登录:

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. 按键盘上的 Windows 键 + R 启动运行"对话框.
  2. 输入regedit并回车打开注册表编辑器
  3. 然后浏览到 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\
  4. 设置 AutoAdminLogon = 1(如果它的字符串变量不存在则创建它)
  5. 设置 DefaultUserName = 您的用户名(如果不存在则创建它,它是一个字符串变量)
  6. 设置 DefaultPassword = 您的密码(如果不存在则创建它,它是一个字符串变量)

来自这篇文章的说明:http://channel9.msdn.com/Blogs/coolstuff/Tip-Auto-Login-Your-Windows-7-User-Account

这篇关于通过 Win32 API 从服务创建 Windows 会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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