Run application on Win7 logon screen [duplicate]

可紊 提交于 2019-12-05 02:12:56

问题


I'd like to run an application on the logon screen of Windows 7 from a service.

I've been doing long researches on this and trying out different ways already, but unfortunately wasn't fully successful so far. I managed to run the application on the lock screen of a currently logged on user - which at first looked to me as it was what I basically tried to achieve. However, I then realized that there are different logon screens for every user and a general one (user independent).

My guess is that this user independent logon screen (that comes up directly after booting when multiple accounts are available or when clicking "switch user" on the lock screen) runs in session 0, while user 1 runs in session 1, user 2 in session 2 and so on. The problem is that if I run an application in session 0 (with "winsta0\winlogon") it's not visible; running in session 1 works fine but doesn't help much as a user has to be already logged in for that.

So how to run an application on the user independent logon/welcome screen? What are the correct parameters and functions for this purpose? Does anybody have a working example for demonstration? (Delphi is preferred but actually any other language will do as well!)


回答1:


The only supported way to do this is to implement a credential provider, as per RRUZ's comment.

If you don't mind breaking the rules, a service running as local system should be able to launch a subprocess in the session of your choice. Use OpenProcessToken to get a handle to your security token, duplicate it with DuplicateTokenEx, use SetTokenInformation to change the token session identifier, then call CreateProcessAsUser to launch the subprocess. (Initially, it would be simplest to use a separate executable, but once you've ironed out the bugs you could roll the service and the subprocess into a single executable, for example by using a command-line argument or an environment variable to distinguish the two cases.)

The WTSGetActiveConsoleSessionId function will tell you which session is currently connected to the physical console.



来源:https://stackoverflow.com/questions/10770929/run-application-on-win7-logon-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!