make an interactive windows service

喜欢而已 提交于 2019-12-02 08:08:57

问题


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

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.

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

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

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

thanks


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/26000543/make-an-interactive-windows-service

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