制作互动式Windows服务 [英] make an interactive windows service

查看:134
本文介绍了制作互动式Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的Java应用程序是一个交互式Windows服务(用户登录时具有GUI的Windows服务)。

I want my Java application to be an interactive windows service (a windows service that has GUI when the user is logged in).

我搜索了这个和我看到这样做的方法是拥有2个程序,第一个是服务,第二个是GUI程序并让它们进行通信 - 服务将从GUI程序中获取命令。

I searched for this and I see that the way to do it is to have 2 programs, 1st is a service, 2nd is a GUI program and make them communicate - the service will get commands from the GUI program.

在我开始拆分程序之前,我注意到在Java Service Wrapper中有一个标志:

Just before I started to split my program, I noticed that in "Java Service Wrapper" there is a flag:


包装器。 ntservice.interactive = TRUE

wrapper.ntservice.interactive=TRUE

这个标志是否自动执行与以下手动配置相同的操作?

Is this flag an automatic way to do the same as the following manual config?


管理工具 - >服务 - >右键单击 - >属性 - >
下登录选项卡选中允许与桌面交互

administrative tools -> services -> right click -> properties -> under Log On tab check allow to interact with desktop

这样有问题吗?我应该走很长的路,把我的程序分成两个程序(GUI和服务)?

Is this way problematic? Should I go for the long way and split my program into two programs (GUI and service)?

谢谢

推荐答案

在Windows Vista之前,所有服务和应用程序都在同一会话中运行。这提供了允许Windows服务具有前端UI并直接与用户交互的便利,但也带来了安全风险。例如,使用提升的用户权限(例如,管理员权限)运行的Windows服务可能会通过利用UI而受到损害。

Prior to Windows Vista, all services and application were run in the same session. This provided the convenience of allowing Windows services to have front-facing UIs and interacting with users directly, but it also posed a security risk. For example, a Windows service that runs with elevated user privileges (e.g., admin rights) could potentially be compromised through exploits of the UI.

从Windows Vista开始,Windows服务在会话0中隔离,而所有用户登录和应用程序在其他会话中运行。从技术上讲,Windows服务仍然可以通过会话0与桌面交互,但普通用户没有方便的方式访问会话0.因此,当您的Windows服务可以弹出确认对话框时,用户将永远不会看到它,因为它显示在Session 0桌面上。此外,用户将无法确认对话框,这意味着Windows服务仍然卡住。

Beginning with Windows Vista, Windows services are isolated in Session 0 while all user logins and applications are run in other sessions. Technically, Windows services can still interact with the desktop via Session 0, but ordinary users have no convenient way of accessing Session 0. So while your Windows service can pop up a confirmation dialog box, the user will never see it because it displays in the Session 0 desktop. Further, the user will be unable to confirm the dialog, meaning that the Windows service remains "stuck."

简而言之,让Windows服务与桌面交互是不行的更长的可行性您必须创建Windows服务,然后创建前端应用程序并为它们提供一些通信方式,例如管道,套接字,共享内存等。在.NET中执行此操作的推荐方法是使用< a href =http://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx\"rel =nofollow> Windows Communication Foundation (WCF)。我不确定使用Java是多么容易,并且本着完全公开的精神,我自己使用套接字。

In short, having your Windows service interact with the desktop is no longer feasible. You'll have to create the Windows service and then a front-end application and provide some means for them to communicate, e.g., pipes, sockets, shared memory, etc. The recommended way to do this in .NET is to use the Windows Communication Foundation (WCF). I'm not sure how easy this is to do w/ Java, and in the spirit of full disclosure, I use sockets myself.

HTH

这篇关于制作互动式Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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