简体   繁体   English

在前景中运行Windows服务

[英]Running Windows Service in Foreground

I have a bat file which is installed as a service. 我有一个作为服务安装的bat文件。 I can run the service on a remote box. 我可以在远程机器上运行该服务。 This service needs to launch another application. 该服务需要启动另一个应用程序。 The launched application needs to be visible(run in foreground). 启动的应用程序必须是可见的(在前台运行)。 Currently the launched application is running in background as the windows service is running in background. 当前,启动的应用程序在后台运行,因为Windows服务在后台运行。 How can i make the windows service or both the windows service and the application that it launches run in foreground? 如何使Windows服务或Windows服务及其启动的应用程序都在前台运行? I intend to manage the service with the ServiceController class in C#. 我打算用C#中的ServiceController类管理服务。

I think you should probably read 我想你应该读

http://asprosys.blogspot.com.au/2009/03/allow-service-to-interact-with-desktop.html http://asprosys.blogspot.com.au/2009/03/allow-service-to-interact-with-desktop.html

Making a service to just launch another app is a real security issue, what if your other app gets replaced with something else do you have all the checks in your Service to ensure your app is the app you think it is. 提供服务以仅启动另一个应用程序是一个真正的安全问题,如果其他应用程序替换为其他应用程序,您会在服务中进行所有检查以确保您的应用程序是您认为的应用程序。

A proper approach is to launch the second application in the user's session, while your Windows service app always runs in session 0. 正确的方法是在用户会话中启动第二个应用程序,而Windows服务应用程序始终在会话0中运行。

The approach has been part of my discussion with @RaheelKhan under this thread, 该方法是我在此线程下与@RaheelKhan讨论的一部分,

How reliable is adding an application manifest to ensure elevated privileges across windows xp, vista and 7? 添加应用程序清单以确保跨Windows XP,Vista和Windows 7的特权提升的可靠性如何?

It requires proper understanding of Windows sessions, session isolation, and platform invoke. 它需要对Windows会话,会话隔离和平台调用有适当的了解。

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

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