简体   繁体   English

如何通过Windows服务登录?

[英]How do I logon Via a Windows Service?

Basically I want a windows Service that at a particular time, Logon on a windows (XP/Vista/7/2008) Machine? 基本上我想要Windows服务,在特定时间在Windows(XP / Vista / 7/2008)计算机上登录? If this is Possible, Please show me the way? 如果可能,请给我指路?

Have a look at CreateProcessWithLogonW, CreateProcessAsUser, LogonUser. 看看CreateProcessWithLogonW,CreateProcessAsUser,LogonUser。 If you look at the 'manpages' on MSDN, that should get you started. 如果您查看MSDN上的“联机帮助页”,那将使您入门。

CreateProcessWithLogonW() CreateProcessWithLogonW()

Granted, as others have mentioned, it is very insecure. 当然,正如其他人提到的那样,这是非常不安全的。

Why do you want to do this? 为什么要这样做? I assume you want to do a graphical logon, not just run code as a particular user without a GUI. 我假设您要进行图形登录,而不仅仅是以没有GUI的特定用户身份运行代码。

Assuming you want to logon with typical user credentials and display the Windows desktop, I think you are going to be out of luck. 假设您要使用典型的用户凭据登录并显示Windows桌面,我想您会很走运。 At least on any platform newer than Windows XP there is strict separation of service and desktop components in the OS. 至少在比Windows XP更新的任何平台上,操作系统中的服务和桌面组件均严格分开。 Windows XP allowed interaction with the desktop but it was a security risk. Windows XP允许与桌面交互,但这存在安全风险。

There is an option in the Services MMC snap-in that details the service user account. 服务MMC管理单元中有一个选项,其中详细说明了服务用户帐户。 If it runs as the local system account there is an option to allow service to interact with the desktop . 如果它作为本地系统帐户运行,则可以选择允许服务与桌面进行交互 I believe the logon desktop is separate from a user desktop which means that you might not be able to interact with it from a service. 我认为登录桌面与用户桌面是分开的,这意味着您可能无法通过服务与之交互。 For instance, things like the CTRL-ALT-DEL sequence cannot be executed from code. 例如,诸如CTRL-ALT-DEL序列之类的东西无法从代码中执行。

AS far as i Know, services cannot interact with the user's desktop. 据我所知,服务无法与用户的桌面进行交互。 I looked into this a while back and never found a good answer. 我回想了一下,却找不到一个好的答案。

There are multiple ways to configure Windows so it automatically log in as a certain user when rebooted - Not sure if that would further your cause. 有多种配置Windows的方法,以便Windows在重新启动后自动以特定用户身份登录-不知道这是否会进一步导致您的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM