从Windows服务登录Windows会话 [英] Logon Windows Session from a Windows Service

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

问题描述

大家好,

我创建了Windows服务,该服务必须控制基于Windows 7 Pro 64的本地计算机.它需要登录和注销会话以及关闭或重新启动计算机.现在,我可以关闭或重新启动计算机,我已经找到一些C#代码可以正常运行.不幸的是,我没有找到登录或注销会话的任何解决方案.我想知道是否有在搜索过程中没有找到的特殊方法吗?

I created a Windows Service that have to control the local computer based on Windows 7 Pro 64. It needs to log-on and log-off session and to shutdown or reboot the computer. For now I can shutdown or reboot the computer, I've found some C# code for that to do that properly. Unfortunately, I didn't found any solution to log-on or log-off session. I want to know if there is a special way that I didn't found during my searches to do that?

这里是上下文:当我启动客户端计算机时,它要求输入用户名和密码来打开Windows 7的会话.当服务从网络上的另一台计算机(我的服务器)收到特殊命令时,我的服务必须在此计算机上打开会话.除了打开(和关闭)会话外,其他所有功能都可以正常运行(我可以从服务器连接到客户端服务并发送命令).

Here is the context: when I start the client computer, it asks for a username and a password to open the Windows 7's session. My service have to open a session on this computer when it receive a special command by another computer (my server) from the network. Everything works perfectly (I can connect to my client service from my server and send commands) except for opening (and closing) session.

我听说过凭据提供程序",但我不完全了解它是什么.如果凭据提供程序可以登录和注销会话,如何在C#中对其进行控制?我可以将一些C/C ++代码制作到DLL中,然后将其加载到C#代码中,但是如果可能的话,我宁愿避免这种情况.

I heard about "Credential Provider", but I don't understand exactly what is it. If Credential Provider can log-on and log-off session, how can I control it in C#? I can make some C/C++ code into a DLL and load it into C# code, but I prefer to avoid that if it's possible.

有人有主意吗?

非常感谢

推荐答案

Nobody有个主意吗?

Nobodies have an idea?

 

我工作中的一个人向我讲述了他过去在Windows XP上所做的事情. XP使用GINA来管理会话.于是他写了一个C/C ++ DLL.但是它太难了,因此他的解决方案是修改Windows注册表以启用自动登录(HKLM \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon并添加/修改具有所需值的键DefaultDomain,DefaultUsername,DefaultPassword,然后打开自动登录将AutoAdminLogon设置为1),然后要求GINA重新加载,它会扫描注册表并自动登录会话.

One person in my work talk me about something he did in the past on Windows XP. XP uses GINA for managing sessions. So he wrote a C/C++ DLL  but it was too hard, so his solution was to modify theWindows Registry to enable auto-login (HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon and add/modify keys DefaultDomain, DefaultUsername, DefaultPassword with the desired values an turn on Autologon with AutoAdminLogon to 1) and then askto GINA to reload, it scan de registry and auto-logon the session.

 

我认为那不是很有效,但是如果有解决方案可以在Windows 7上做到这一点(因为GINA在7上已经不存在),我会接受的.我的老板给我讲了一个比上述XP解决方案有效得多的解决方案:按说明修改注册表,然后重新启动计算机....我只能添加一件事,请帮助我,我可以"不能编写这样的解决方案,那是不人道的!".

That's not very effective I think but if there's a solution to do that on Windows 7 (since GINA doesn't exist anymore on 7) I'll take it. My boss talk me about a solution much less effective than the XP solution describe above: modify the registry as describes and then reboot the computer.... I have only one thing to add for this "please help me, I just can't code a solution like that, it's inhuman!".

 

谢谢


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

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