在 Win7 登录屏幕上运行应用程序 [英] Run application on Win7 logon screen

查看:23
本文介绍了在 Win7 登录屏幕上运行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过服务在 Windows 7 的登录屏幕上运行应用程序.

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).

我的猜测是这个用户独立登录屏幕(当多个帐户可用或在锁定屏幕上单击切换用户"时在启动后直接出现)在会话 0 中运行,而用户 1 在会话 1 中运行,用户会话 2 中的 2,依此类推.问题是,如果我在会话 0(使用winsta0\winlogon")中运行一个应用程序,它是不可见的;在会话 1 中运行工作正常,但没有太大帮助,因为用户必须已经登录.

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.

那么如何在独立于用户的登录/欢迎屏幕上运行应用程序?为此目的,正确的参数和功能是什么?有人有演示的工作示例吗?(Delphi 是首选,但实际上任何其他语言也可以!)

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!)

推荐答案

根据 RRUZ 的评论,唯一支持的方法是实现凭据提供程序.

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

如果您不介意违反规则,作为本地系统运行的服务应该能够在您选择的会话中启动子进程.使用 OpenProcessToken 要获取安全令牌的句柄,请使用 DuplicateTokenEx,使用SetTokenInformation 更改令牌会话标识符,然后调用 CreateProcessAsUser 以启动子进程.(最初,使用单独的可执行文件是最简单的,但是一旦您解决了错误,您就可以将服务和子进程合并为一个可执行文件,例如通过使用命令行参数或环境变量来区分两种情况.)

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.)

WTSGetActiveConsoleSessionId 函数将告诉您当前连接到物理控制台的会话.

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

这篇关于在 Win7 登录屏幕上运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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