开发者

How do I logon Via a Windows Service?

开发者 https://www.devze.com 2022-12-10 11:55 出处:网络
Basically I want a windows Service that at a particular time, Logon on a windows (XP/Vista/7开发者_如何学JAVA/2008) Machine? If this is Possible, Please show me the way?Have a look at CreateProcessWit

Basically I want a windows Service that at a particular time, Logon on a windows (XP/Vista/7开发者_如何学JAVA/2008) Machine? If this is Possible, Please show me the way?


Have a look at CreateProcessWithLogonW, CreateProcessAsUser, LogonUser. If you look at the 'manpages' on MSDN, that should get you started.

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.

Assuming you want to logon with typical user credentials and display the Windows desktop, I think you are going to be out of luck. At least on any platform newer than Windows XP there is strict separation of service and desktop components in the OS. Windows XP allowed interaction with the desktop but it was a security risk.

There is an option in the Services MMC snap-in that details the service user account. 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消