且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

每当Windows服务启动时自动打开一个exe

更新时间:2023-01-30 08:53:34

除了解决方案1中给出的信息之外,还要注意Windows服务不能直接与用户会话交互。对于Windows 7,这是一个严格的规则,称为会话0隔离(与XP不同,它仍然可以通过一些设置 - 虽然已经不鼓励)。因此,具有GUI的程序对于任何人都是可见的。

当登录用户想要与服务交互时,可以使用诸如.Net Remoting,WCF等其他一些技术。 。
Beyond the information given in solution 1, also note that a Windows Service MUST NOT interact directly with a user session. With Windows 7, that is a strict rule, called "session 0 isolation" (different from XP where it was still possible with some settings - though already discouraged). Consequently, that program with a GUI would be visible to nobody at all.
When a logged in user wants to interact with a service, some other technologies like .Net Remoting, WCF, etc. can be used.


这听起来像是马前的车问题。 Windows服务在计算机启动时以及任何用户登录之前启动。如果您的程序具有UI,则您几乎需要使用活动桌面登录才能显示程序UI。



有合理的例外,但您的描述不完整,可能无法完成。
This sounds like a "cart before the horse" problem. Windows Services start when the machine boots, and before any user logs in. If you have a program that has a UI, you pretty much need a user logged in with an active desktop to display the program UI.

There are reasonable exceptions to this but your description is not complete and likely can't be done.