2

我正在尝试从从服务启动的可执行文件中删除 Windows 登录屏幕 (winlogon)。该服务将自动启动 windows 并等待来自另一台计算机的命令。当它接收到命令时,它将启动一个 exe,该 exe 将在特定用户名下启动 cmd.exe。

该服务已经存在。我有编写这个可执行文件的工作。目前,我已经编写了可执行文件 (CmdLogin),它通过调用 LogonUserW、ImpersonateUser 和 CreateProcessWithLogonW 在不同的用户下启动 cmd.exe。我将 lpDesktop 指定为“WinSta0\Default”。唯一的问题是该服务必须在管理员帐户下运行(但这是一个不同的问题)。

当从命令提示符调用时(即使在 Windows 7 上),它工作得非常好。当用户登录并查看他的桌面时从服务调用时,这也有效(就像我在同一台机器上调试时所做的那样)。但是,就像我上面所说的,我真正的要求是即使在显示 Windows 登录屏幕时也能正常工作。目前,exe 给出了正确的退出代码,但没有出现该窗口。但是,当用户登录时,他会在桌面上看到 cmd 窗口。

我发现的一种解决方案是对 lpDesktop 使用“WinSta0\WinLogon”而不是 Default。我还没有尝试这个。但是,这看起来会在登录屏幕上显示 cmd 窗口。我真正需要的是实际模拟用户登录到 winlogon 并显示他的实际桌面(和 cmd 窗口)。

我环顾四周,发现了 GINA 和 Winlogon 通知包。他们似乎有点过头了,我不确定这是否能解决这里的目的。此外,这些在 Windows Vista 中已被弃用,这让我认为有更好、更简洁的方法来解决这个问题。

关于我应该使用什么来实现这一目标的任何建议?作为记录,可执行文件在 C# 中,使用 P/Invoke 进行 API 调用。我也愿意使用可以从此 C# 应用程序调用的 C dll。

谢谢你,
侯赛因

4

1 回答 1

2

GINA has been superceded in Vista/2008 by Credential Providers (not available in managed code).

I don't know how to do what you need, but perhaps this is a clue to go further down the trail.

And for the record, this seems like the wrong way to address the problem. I just don't see how you would need to run a command prompt under an auto login... Why not write a service to do your tasks, and have it run under a set of service specific credentials?

I don't have the background on your problem, but this description makes me shudder. :-)

[Update] Well, in response to your comment. I would say that writing a GINA replacement for <= Windows 2003, or a custom credential provider for Vista/2008+ would look to be your best option.

You can provide custom authentication against his credential store, then allow or deny the login as you see fit.

于 2009-07-07T01:28:47.567 回答